修改fromappid 获得逻辑
This commit is contained in:
parent
a4a75bc628
commit
24888296a7
@ -88,7 +88,7 @@ class Report:
|
||||
def __init__(self, day, project):
|
||||
self.day = day
|
||||
self.project = project
|
||||
|
||||
self.not_minigames = (2001, 2002)
|
||||
|
||||
def get_all_data(self, **args):
|
||||
activa_sql = f"""SELECT
|
||||
@ -175,7 +175,7 @@ class Report:
|
||||
and "channel"='{args['channelid']}'
|
||||
AND activity_id=201
|
||||
and "$part_date"='{self.day}' """
|
||||
if args['gameid'] not in (2001, 2002):
|
||||
if args['gameid'] not in self.not_minigames:
|
||||
jumpout_sql = f"""SELECT
|
||||
count(distinct "#account_id")
|
||||
FROM
|
||||
@ -275,7 +275,7 @@ class Report:
|
||||
|
||||
|
||||
def get_output_fromappid(self, **args):
|
||||
if args['gameid'] not in (2001, 2002):
|
||||
if args['gameid'] not in self.not_minigames:
|
||||
jump_sql = f"""SELECT
|
||||
count("#account_id"),count(distinct "#account_id")
|
||||
FROM
|
||||
@ -327,6 +327,69 @@ class Report:
|
||||
else:
|
||||
return None
|
||||
|
||||
def get_ss_input_fromappid(self, args):
|
||||
if args['gameid'] not in self.not_minigames:
|
||||
sql = f"""select distinct from_appid FROM
|
||||
v_event_{args['suffix']}
|
||||
where
|
||||
"$part_event"='event_11_1'
|
||||
and gameid='{args['gameid']}'
|
||||
and "channel"='{args['channelid']}'
|
||||
and "$part_date"='{self.day}'"""
|
||||
data = args['tga'].get_data(sql)
|
||||
input_fromappids = list()
|
||||
if data:
|
||||
try:
|
||||
for line in data:
|
||||
if line:
|
||||
input_fromappids.append(line[0])
|
||||
except Exception:
|
||||
log.error(f"split {line} error", exc_info=True)
|
||||
return input_fromappids
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
def get_ss_output_fromappid(self, args):
|
||||
output_fromappids = list()
|
||||
if args['gameid'] not in self.not_minigames:
|
||||
sql = f"""select distinct from_appid FROM
|
||||
v_event_{args['suffix']}
|
||||
where
|
||||
"$part_event"='event_1_4'
|
||||
and gameid='{args['gameid']}'
|
||||
and "channel"='{args['channelid']}'
|
||||
and "$part_date"='{self.day}'"""
|
||||
data = args['tga'].get_data(sql)
|
||||
if data:
|
||||
try:
|
||||
for line in data:
|
||||
if line:
|
||||
output_fromappids.append(line[0].split('_success')[0])
|
||||
except Exception:
|
||||
log.error(f"split {line} error", exc_info=True)
|
||||
return output_fromappids
|
||||
else:
|
||||
sql = f"""select distinct button_name FROM
|
||||
v_event_{args['suffix']}
|
||||
where
|
||||
"$part_event"='event_11_31'
|
||||
and gameid='{args['gameid']}'
|
||||
and "channel"='{args['channelid']}'
|
||||
and "$part_date"='{self.day}'
|
||||
and button_name like 'wx%_success'"""
|
||||
|
||||
data = args['tga'].get_data(sql)
|
||||
if data:
|
||||
try:
|
||||
for line in data:
|
||||
if line:
|
||||
output_fromappids.append(line[0])
|
||||
except Exception:
|
||||
log.error(f"split {line} error", exc_info=True)
|
||||
return output_fromappids
|
||||
|
||||
|
||||
|
||||
def run(self):
|
||||
if self.project == 'mini_games':
|
||||
@ -347,7 +410,6 @@ class Report:
|
||||
for item in parms:
|
||||
args = {}
|
||||
args['gameid'], args['channelid'] = item
|
||||
# key = f"{args['gameid']}#{args['channelid']}"
|
||||
|
||||
temp = {}
|
||||
temp['gameid'] = game_cn.get(args['gameid'], None)
|
||||
@ -366,24 +428,29 @@ class Report:
|
||||
args['tga'] = tga
|
||||
|
||||
temp['all'] = self.get_all_data(**args)
|
||||
ss_input_fromappids = self.get_ss_input_fromappid(args)
|
||||
ss_output_fromappids = self.get_ss_output_fromappid(args)
|
||||
|
||||
mp = MpInterface()
|
||||
fromappids = mp.get_fromappid_cn(args['gameid'], args['channelid'])
|
||||
f_keys = fromappids.keys()
|
||||
if f_keys:
|
||||
for f_key in f_keys:
|
||||
args['fromappid'] = f_key
|
||||
args['fromappid_cn'] = fromappids.get(f_key, None) or "未知"
|
||||
# 2001 暂无买量数据
|
||||
if args['gameid'] not in (2001, 2002):
|
||||
temp['input'].append(self.get_input_fromappid(**args))
|
||||
temp['output'].append(self.get_output_fromappid(**args))
|
||||
print(temp)
|
||||
data.append(temp)
|
||||
if f_keys and ss_input_fromappids:
|
||||
for item in ss_input_fromappids:
|
||||
args['fromappid'] = item
|
||||
args['fromappid_cn'] = f_keys.get(item, None) or "未知"
|
||||
temp['input'].append(self.get_input_fromappid(**args))
|
||||
data.append(temp)
|
||||
|
||||
if f_keys and ss_output_fromappids:
|
||||
for item in ss_output_fromappids:
|
||||
args['fromappid'] = item
|
||||
args['fromappid_cn'] = f_keys.get(item, None) or "未知"
|
||||
temp['output'].append(self.get_input_fromappid(**args))
|
||||
data.append(temp)
|
||||
|
||||
return data
|
||||
|
||||
|
||||
|
||||
|
||||
def main():
|
||||
day = (datetime.date.today() - datetime.timedelta(days=1)).strftime('%Y-%m-%d')
|
||||
project = 'mini_games'
|
||||
|
Loading…
x
Reference in New Issue
Block a user