|
@@ -22,12 +22,11 @@ class UnitHourlyReport:
|
|
|
|
|
|
def hourly_report(self):
|
|
|
try:
|
|
|
- sql = """select count(1) from media_api.kuaishou_unit_report_hourly where
|
|
|
- stat_date between {start_time} and {end_time}""".format(
|
|
|
+ sql = """select advertiser_id from media_api.kuaishou_unit_report_hourly where
|
|
|
+ stat_date between {start_time} and {end_time} group by 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_hourly_dw
|
|
|
(account_id, stat_date,`hour`, campaign_id, campaign_name, unit_id, unit_name, project_id, product_id, advertiser_id,
|
|
|
company_id, account_name, project_name, advertiser_name, company_name, sale_id, user_id, org_code, charge, `show`, photo_click, aclick, bclick, photo_click_ratio, play_3s_ratio, action_ratio,
|
|
@@ -207,8 +206,8 @@ class UnitHourlyReport:
|
|
|
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,hour,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} and 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()
|
|
@@ -226,4 +225,4 @@ if __name__ == '__main__':
|
|
|
exit(0)
|
|
|
else:
|
|
|
print("作业执行失败")
|
|
|
- exit(-1)
|
|
|
+ exit(-1)
|