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