From be599172d6902351cd41e8d7ef389d69d61f2eb9 Mon Sep 17 00:00:00 2001 From: haoqiyue <1293971940@qq.com> Date: Thu, 2 Mar 2023 14:30:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=96=B0=E5=A2=9E=E4=BB=98?= =?UTF-8?q?=E8=B4=B9=E8=AE=BE=E5=A4=87owner=E7=AD=9B=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/behavior_analysis.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/models/behavior_analysis.py b/models/behavior_analysis.py index abc7356..37d046b 100644 --- a/models/behavior_analysis.py +++ b/models/behavior_analysis.py @@ -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)