修改DB 指向AD数据库
This commit is contained in:
parent
3176825abe
commit
8441a11418
@ -45,27 +45,99 @@ import pdb
|
|||||||
# 'distinct_id': '$_id', 'object_id': '$_id', '_id': 0}}]
|
# 'distinct_id': '$_id', 'object_id': '$_id', '_id': 0}}]
|
||||||
#
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# {
|
||||||
|
# "_id" : ObjectId("5d92b4f713c3487bd374c691"),
|
||||||
|
# "tags" : [
|
||||||
|
# "魔性",
|
||||||
|
# "io",
|
||||||
|
# "休闲"
|
||||||
|
# ],
|
||||||
|
# "source" : "taptap",
|
||||||
|
# "cateName" : "download",
|
||||||
|
# "icon" : "https://img.tapimg.com/market/lcs/601735dfe48b2fbac327851d75b0dc72_360.png?imageMogr2/auto-orient/strip",
|
||||||
|
# "order" : 1,
|
||||||
|
# "title" : "我的大刀四十米(测试版)",
|
||||||
|
# "author" : "厂商: 睡神飞工作室",
|
||||||
|
# "score" : 8.6,
|
||||||
|
# "desc" : "明明可以靠抄袭,偏偏却要死磕原创。我不知道明明是谁,反正我们是偏偏。全新玩法io类游戏来啦!魔性欢快地砍来砍去吧!开局一把刀越砍刀越长谁挡我砍谁我长我有理不服来砍我睡神飞工作室继《我飞刀玩得贼6》之后又一新品!魔性翻倍!快乐翻倍!",
|
||||||
|
# "cate" : "休闲",
|
||||||
|
# "gameid" : 176279,
|
||||||
|
# "date" : "2019-09-30",
|
||||||
|
# "watch" : 118674,
|
||||||
|
# "reserve" : 0,
|
||||||
|
# "sell" : 0,
|
||||||
|
# "download" : 0,
|
||||||
|
# "review" : 274,
|
||||||
|
# "topic" : 49,
|
||||||
|
# "__v" : 0,
|
||||||
|
# "createdAt" : ISODate("2019-10-01T02:07:51.256Z"),
|
||||||
|
# "updatedAt" : ISODate("2019-10-01T02:07:51.256Z")
|
||||||
|
# }
|
||||||
|
|
||||||
|
from ops.mtga import FromTga
|
||||||
|
from ops.plog import define_logger
|
||||||
|
import logging
|
||||||
|
import datetime
|
||||||
|
|
||||||
|
define_logger("/data/logs/ops/reptile2ss.log")
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
MONGOINFO = {'host': '10.10.5.6', 'port': 27017}
|
||||||
|
|
||||||
|
|
||||||
class CollectMongo():
|
class CollectMongo():
|
||||||
def __init__(self):
|
def __init__(self, item):
|
||||||
|
self.url = "http://10.10.3.17:8992/querySql"
|
||||||
|
self.api_secret = "GsFnzuKcNOFXsRJbDjV3avy67wTl8tyRD0t0b0VOFbQ285StWmkvT32gtQBVycXp"
|
||||||
|
self.tga = FromTga(url=self.url, token=self.api_secret)
|
||||||
|
self.item = item
|
||||||
|
self.tgaid = self.item.get('tgaid')
|
||||||
|
# 初始化tga写方法初始化
|
||||||
|
self.tga.init_tga_write(self.tgaid)
|
||||||
|
|
||||||
|
|
||||||
|
def get_data_from_mongo(self):
|
||||||
|
dbset = MONGOINFO.copy()
|
||||||
|
dbset['dbname'] = self.item.get('db')
|
||||||
|
dbset['collname'] = self.item.get('coll')
|
||||||
|
|
||||||
|
m = MongodbBase(**dbset)
|
||||||
|
data = list(m.query(self.item.get('pipeline')))
|
||||||
|
# print(data)
|
||||||
|
return data
|
||||||
|
|
||||||
|
def write2ss(self, data):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def read_mongo(self):
|
def run(self):
|
||||||
args = dict()
|
data = self.get_data_from_mongo()
|
||||||
args['host'] = '10.10.5.6'
|
print(data)
|
||||||
args['port'] = 27017
|
self.write2ss(data)
|
||||||
args['dbname'] = 'taptap'
|
|
||||||
args['collname'] = 'games'
|
|
||||||
pdb.set_trace()
|
def read_mongo(start_date, end_date):
|
||||||
m = MongodbBase(**args)
|
all_type = []
|
||||||
r = m.query()
|
reptile_4_1 = {}
|
||||||
print(f"get from mongodb was {r}")
|
reptile_4_1['db'] = "taptap"
|
||||||
|
reptile_4_1['coll'] = "games"
|
||||||
|
reptile_4_1['event_name'] = "reptile_4_1"
|
||||||
|
reptile_4_1['gameid'] = 9999
|
||||||
|
reptile_4_1['tgaid'] = 6
|
||||||
|
reptile_4_1['pipeline'] = [{'$match': {'createdAt': {'$gte': start_date, '$lt': end_date}}}, {
|
||||||
|
'$project': {'tags': 1, 'source': 1, 'cateName': 1, 'icon': 1, 'order': 1, 'title': 1, 'author': 1, 'score': 1,
|
||||||
|
'desc': 1, 'cate': 1, 'gameid': 1, 'date': 1, 'watch': 1, 'reserve': 1, 'sell': 1, 'download': 1,
|
||||||
|
'review': 1, 'topic': 1, 'createdAt': 1, 'updatedAt': 1, 'object_id': '$_id', '_id': 0}}]
|
||||||
|
all_type.append(reptile_4_1)
|
||||||
|
for item in all_type:
|
||||||
|
cc = CollectMongo(item)
|
||||||
|
cc.run()
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
cc = CollectMongo()
|
|
||||||
cc.read_mongo()
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
d = datetime.datetime.now() - datetime.timedelta(days=1)
|
||||||
|
start_date = datetime.datetime(d.year, d.month, d.day)
|
||||||
|
end_date = datetime.datetime(d.year, d.month, d.day, 23, 59, 59)
|
||||||
|
read_mongo(start_date, end_date)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user