Compare commits

...

3 Commits

Author SHA1 Message Date
129d4f229c update 2020-11-18 15:15:11 +08:00
c5504195d3 Merge branch 'master' of http://git.legu.cc/wuhao/xgame_attr_sync 2020-11-18 15:14:14 +08:00
b8db79d56f init 2020-11-18 15:11:21 +08:00
2 changed files with 41 additions and 0 deletions

1
.gitignore vendored
View File

@ -129,3 +129,4 @@ dmypy.json
# Pyre type checker
.pyre/
.idea

40
main.py Normal file
View File

@ -0,0 +1,40 @@
""""
用于同步 atrr 配置
1.关键指标 运营日报
2.新手漏斗
"""
import os
import sys
import pymongo
# source_mongo_uri = 'mongodb://root:Legu2020@dds-hp35c58764c35aa41188-pub.mongodb.huhehaote.rds.aliyuncs.com:3717,dds-hp35c58764c35aa42908-pub.mongodb.huhehaote.rds.aliyuncs.com:3717/admin?replicaSet=mgset-421510732'
# local_mongo_uri = 'mongodb://root:iamciniao@119.29.176.224:27017/?authSource=admin&readPreference=primary&ssl=false'
source_mongo_uri = os.getenv('remote_mdb_uri')
local_mongo_uri = os.getenv('local_mdb_uri')
s_cline = pymongo.MongoClient(source_mongo_uri)
d_cline = pymongo.MongoClient(local_mongo_uri)
def get_pname():
data = s_cline['admin_game']['kv'].find_one({'k': 'attr_sync'})
return data['v']
def sync_data(game):
s_coll = s_cline['game_' + game]['attr']
d_coll = d_cline['game_' + game]['attr']
for pname in get_pname():
where = {'pname': pname}
doc = s_coll.find_one(where, {'_id': 0})
if not doc:
continue
d_coll.update_one(where, {'$set': doc},upsert=True)
if __name__ == '__main__':
game = sys.argv[1]
sync_data(game)