From b5de055dcab158fa8c1084f829a73201fb317bcb Mon Sep 17 00:00:00 2001 From: kf_wuhao <15392746632@qq.com> Date: Wed, 24 Feb 2021 18:07:25 +0800 Subject: [PATCH] update --- task/login_repair.py | 9 ++++++--- task/summary3.py | 8 +++++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/task/login_repair.py b/task/login_repair.py index 6b40701..86972dc 100644 --- a/task/login_repair.py +++ b/task/login_repair.py @@ -16,7 +16,7 @@ class LoginRepair(Task): class Model(GBaseModel): cdate: int = Field(..., title='当天0点') - # first_device_id: str = Field(None, title='第一次登录设备id', alias='_first_device_id') + first_device_id: str = Field(None, title='第一次登录设备id', alias='_first_device_id') manufacturer: str = Field(None, title='设备品牌', alias='_manufacturer') model: str = Field(None, title='型号', alias='_model') os_version: str = Field(None, title='系统版本', alias='_os_version') @@ -48,8 +48,11 @@ class LoginRepair(Task): # 还没有记录的 role_set = set(role_list) - set(exists_role_list) for role_id in role_set: - item = self.local_db[source_coll].find_one( - {'_game_role_id': role_id, '_event_name': 'TimeSpending'}, projection) + # logger.debug(f'add {role_id}') + item = self.local_db['user'].find_one( + {'_game_role_id': role_id}, projection) + if not item: + continue try: item['cdate'] = int(pd.Timestamp(item['_event_time'], unit='s', tz=self.timezone) \ .normalize().timestamp()) diff --git a/task/summary3.py b/task/summary3.py index 5e30711..1027bd7 100644 --- a/task/summary3.py +++ b/task/summary3.py @@ -260,12 +260,18 @@ class Summary3(Task): self.local_db[f'summary_{cat}'].update_one({'_id': data['_id']}, {'$set': data}) self.remote_db[f'summary_{cat}'].update_one({'_id': data['_id']}, {'$set': data}) # 计算累计充值 + type_map = { + 'role': '_game_role_id', + 'account': '_channel_uid', + 'device': '_device_id', + } + for id_, doc in update_doc.items(): pipeline = [ { '$match': { "cdate": {'$gte': doc['cdate'], '$lte': cdate}, - f'_game_{cat}_id': {'$in': doc[f'now_pay_{cat}_list']}, + type_map[cat]: {'$in': doc[f'now_pay_{cat}_list']}, } }, {'$group': {'_id': None, 'sum_money': {'$sum': '$money'}}}