renyupeng пре 3 година
родитељ
комит
2a5ce3018f
1 измењених фајлова са 7 додато и 7 уклоњено
  1. 7 7
      Apietl/kwai_etl/report/UnitDailyReport.py

+ 7 - 7
Apietl/kwai_etl/report/UnitDailyReport.py

@@ -26,12 +26,11 @@ class UnitDailyReport:
         ReplaceAccountInfo.handler()
         try:
             sql = """
-            select count(1) from media_api.kuaishou_unit_report_daily where 
-            stat_date between {start_time} and {end_time}""".format(
+            select advertiser_id from media_api.kuaishou_unit_report_daily where 
+            stat_date between {start_time} and {end_time} group advertiser_id""".format(
                 start_time=self.start_time, end_time=self.end_time)
-            totalNum = TidbConn.quary(sql)[0][0]
-            pageCount = ceil(totalNum / 10000)
-            for i in range(pageCount):
+            account_list = TidbConn.quary(sql)
+            for account_id in account_list:
                 sql = """
                 replace into application.kuaishou_unit_report_daily_dw
 (account_id, stat_date, campaign_id, campaign_name, unit_id, unit_name, project_id, product_id, advertiser_id,
@@ -211,8 +210,9 @@ class UnitDailyReport:
                  left join
              `jeecg-boot`.ctop_account_attribution_info sys
              on report.advertiser_id = sys.account_id
-        where report.stat_date between {start_time} and {end_time} order by unit_id,stat_date limit {num},10000""".\
-                    format(start_time=self.start_time, end_time=self.end_time, num=i * 10000)
+        where report.stat_date between {start_time} and {end_time}
+        where report.advertiser_id={account_id}""".\
+                    format(start_time=self.start_time, end_time=self.end_time, account_id=account_id[0])
                 print(sql)
                 TidbConn.upsert(conn=self.conn, sql_buff=sql)
                 self.conn.commit()