|
@@ -20,13 +20,12 @@ class CampaignHourlyReport:
|
|
self.conn = TidbConn.get_connection()
|
|
self.conn = TidbConn.get_connection()
|
|
self.parm = Utils.get_args()
|
|
self.parm = Utils.get_args()
|
|
self.start_time = self.parm[0]
|
|
self.start_time = self.parm[0]
|
|
- self.end_time = self.parm[1]
|
|
|
|
|
|
|
|
def hourly_report(self):
|
|
def hourly_report(self):
|
|
try:
|
|
try:
|
|
sql = """select advertiser_id from media_api.kuaishou_campaign_report_hourly where
|
|
sql = """select advertiser_id from media_api.kuaishou_campaign_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)
|
|
|
|
|
|
+ stat_date = {start_time} and cost>0 group by advertiser_id""".format(
|
|
|
|
+ start_time=self.start_time, end_time=self. end_time)
|
|
account_list = TidbConn.quary(self.conn, sql)
|
|
account_list = TidbConn.quary(self.conn, sql)
|
|
for account_id in account_list:
|
|
for account_id in account_list:
|
|
sql = """replace into application.kuaishou_campaign_report_hourly_dw
|
|
sql = """replace into application.kuaishou_campaign_report_hourly_dw
|
|
@@ -230,8 +229,8 @@ WHERE
|
|
cua.account_id IS NOT NULL
|
|
cua.account_id IS NOT NULL
|
|
) sys
|
|
) sys
|
|
on report.advertiser_id = sys.account_id
|
|
on report.advertiser_id = sys.account_id
|
|
- 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])
|
|
|
|
|
|
+ where report.stat_date = {start_time} and report.advertiser_id = {account_id}""". \
|
|
|
|
+ format(start_time=self.start_time, account_id=account_id[0])
|
|
print(sql)
|
|
print(sql)
|
|
TidbConn.upsert(conn=self.conn, sql_buff=sql)
|
|
TidbConn.upsert(conn=self.conn, sql_buff=sql)
|
|
self.conn.commit()
|
|
self.conn.commit()
|