优化新增付费设备owner筛选

This commit is contained in:
haoqiyue 2023-03-02 14:30:56 +08:00
parent d02b25e5c0
commit be599172d6

View File

@ -744,16 +744,28 @@ class BehaviorAnalysis:
stat_date = self.start_date
end_date = self.end_date
game = self.game
# 截取原始sql中动态条件部分
aa = r'anon_1(.*?)addHours'
dt_where = re.findall(aa, str(sql))
dt_where2 = (dt_where[0]).split("AND ")
if len(dt_where2) > 2:
bb = ""
for i in range(len(dt_where2) - 1):
if i > 0:
bb += " AND " + dt_where2[i]
else:
bb = ""
sql = f"""
select p.date ,round(uniqExact(p."#distinct_id"),2) AS values from
(select toDate(addHours({game}.event."#event_time", 8)) as date,"#distinct_id" from
{game}.event where `#event_name` = 'pay' and addHours({game}.event.`#event_time`, 8) >= '{stat_date}' and addHours({game}.event.`#event_time`, 8) <= '{end_date}' group by date, "#distinct_id") p
select p.date ,round(uniqExact(p."#distinct_id"),2) AS values from
(select toDate(addHours({game}.event."#event_time", 8)) as date,"#distinct_id" from
{game}.event where `#event_name` = 'pay' and addHours({game}.event.`#event_time`, 8) >= '{stat_date}' and addHours({game}.event.`#event_time`, 8) <= '{end_date}' {bb} group by date, "#distinct_id") p
inner join
(SELECT toDate(addHours({game}.event."#event_time", 8)) as date,"#distinct_id" FROM {game}.event WHERE
addHours({game}.event."#event_time", 8) >= '{stat_date}'
AND addHours({game}.event."#event_time", 8) <= '{end_date}'
AND {game}.event."#event_name" = '{check_event}'
AND {game}.event.is_new_device = '1') d on p."#distinct_id" = d."#distinct_id" and p.date = d.date group by date """
AND {game}.event.is_new_device = '1' {bb}) d on p."#distinct_id" = d."#distinct_id" and p.date = d.date group by date """
#充值总额
if event_name_display == '充值总额':
sql=sql.replace("""GROUP BY toDate(addHours(huixie.event."#event_time", 8)) ORDER BY date
LIMIT 100000""",'',1)