新增付费设备数特殊处理

This commit is contained in:
haoqiyue 2023-02-24 15:53:00 +08:00
parent 32bebc800d
commit e50780e273

View File

@ -735,6 +735,25 @@ class BehaviorAnalysis:
qry = qry.order_by(sa.Column('values').desc())
qry = qry.limit(100000)
sql = str(qry.compile(compile_kwargs={"literal_binds": True}))
# 新增付费设备数单独进行sql处理
if event_name_display == '新增付费设备数':
if "huixie" in self.game:
check_event = "new_device"
else:
check_event = "create_account"
stat_date = self.start_date
end_date = self.end_date
game = self.game
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
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 """
if event_name_display == '充值总额':
sql=sql.replace("""GROUP BY toDate(addHours(huixie.event."#event_time", 8)) ORDER BY date
LIMIT 100000""",'',1)