|
@@ -15,32 +15,29 @@ du = DateUtils()
|
|
|
|
|
|
def run(dt):
|
|
|
sql = f"""
|
|
|
- SELECT a.dt,b.type,count(*) as ct,sum(a.cost),sum(view_count),sum(click_count),
|
|
|
+ SELECT a.dt,a.type,count(*) as ct,sum(a.cost),sum(view_count),sum(click_count),
|
|
|
sum(follow_count),sum(order_count),sum(order_amount),
|
|
|
title,description,book,platform,stage,e.channel,pitcher,ifnull(image_id,''),
|
|
|
- g.created_time,g.campaign_id
|
|
|
+ g.created_time,a.campaign_id
|
|
|
from
|
|
|
ad_cost_day a
|
|
|
left join ad_info b on a.ad_id=b.ad_id
|
|
|
left join adcreative_info c on b.adcreative_id=c.adcreative_id
|
|
|
- left join channel_by_account_daily e on b.account_id=e.account_id and a.dt=e.dt
|
|
|
+ left join channel_by_account_daily e on a.account_id=e.account_id and a.dt=e.dt
|
|
|
left join channel_info_daily f on e.channel=f.channel and e.dt=f.dt
|
|
|
- left join campaign_info g on b.campaign_id = g.campaign_id
|
|
|
- where a.dt='{dt}' and (c.is_video=0 or c.is_video is null) and g.campaign_id is not null
|
|
|
- group by g.campaign_id
|
|
|
+ left join campaign_info g on a.campaign_id = g.campaign_id
|
|
|
+ where a.dt='{dt}' and (c.is_video=0 or c.is_video is null)
|
|
|
+ and a.campaign_id is not null
|
|
|
+ group by a.campaign_id
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
data = db.quchen_text.get_data_list(sql)
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
|
|
|
|
|
|
li = []
|
|
|
for i in data:
|
|
|
-
|
|
|
li.extend(i[16].split(','))
|
|
|
|
|
|
|
|
@@ -148,28 +145,28 @@ def run(dt):
|
|
|
data = data_new
|
|
|
|
|
|
sql_video = f""" select foo.*,if(foo2.pitcher,foo2.pitcher,foo.pitcher) as owner from
|
|
|
- (SELECT a.dt,b.type,count(*),sum(a.cost),sum(view_count),sum(click_count),sum(follow_count),sum(order_count),sum(order_amount),
|
|
|
+ (SELECT a.dt,a.type,count(*),sum(a.cost),sum(view_count),sum(click_count),sum(follow_count),sum(order_count),sum(order_amount),
|
|
|
title,description,book,platform,stage,e.channel,pitcher,ifnull(image_id,''),g.preview_url,g.signature,1,
|
|
|
g.width,g.height,g.`size` ,g.`type` as video_type ,g.video_length ,g.byte_rate ,g.video_meta_data,g.download_path
|
|
|
- ,min(h.created_time) as created_time , h.campaign_id
|
|
|
+ ,min(h.created_time) as created_time , a.campaign_id
|
|
|
from
|
|
|
ad_cost_day a
|
|
|
left join ad_info b on a.ad_id=b.ad_id
|
|
|
left join adcreative_info c on b.adcreative_id=c.adcreative_id
|
|
|
- left join channel_by_account_daily e on b.account_id=e.account_id and a.dt=e.dt
|
|
|
+ left join channel_by_account_daily e on a.account_id=e.account_id and a.dt=e.dt
|
|
|
left join channel_info_daily f on e.channel=f.channel and e.dt=f.dt
|
|
|
left join video_info g on c.image_id=g.video_id
|
|
|
- left join campaign_info h on b.campaign_id = h.campaign_id
|
|
|
+ left join campaign_info h on a.campaign_id = h.campaign_id
|
|
|
where a.dt='{dt}' and c.is_video=1 and h.campaign_id is not null
|
|
|
- group by h.campaign_id) as foo
|
|
|
- inner join
|
|
|
+ group by a.campaign_id) as foo
|
|
|
+ left join
|
|
|
(select signature,pitcher from ad_cost_day a
|
|
|
left join ad_info b on a.ad_id=b.ad_id
|
|
|
left join adcreative_info c on b.adcreative_id=c.adcreative_id
|
|
|
- left join channel_by_account_daily e on b.account_id=e.account_id and a.dt=e.dt
|
|
|
+ left join channel_by_account_daily e on a.account_id=e.account_id and a.dt=e.dt
|
|
|
left join channel_info_daily f on e.channel=f.channel and e.dt=f.dt
|
|
|
left join video_info g on c.image_id=g.video_id
|
|
|
- left join campaign_info h on b.campaign_id = h.campaign_id
|
|
|
+ left join campaign_info h on a.campaign_id = h.campaign_id
|
|
|
where a.dt='{dt}' and c.is_video=1 and h.campaign_id is not null
|
|
|
and (signature,h.created_time) in
|
|
|
(select signature,min(h.created_time) as created_time
|
|
@@ -177,10 +174,10 @@ def run(dt):
|
|
|
ad_cost_day a
|
|
|
left join ad_info b on a.ad_id=b.ad_id
|
|
|
left join adcreative_info c on b.adcreative_id=c.adcreative_id
|
|
|
- left join channel_by_account_daily e on b.account_id=e.account_id and a.dt=e.dt
|
|
|
+ left join channel_by_account_daily e on a.account_id=e.account_id and a.dt=e.dt
|
|
|
left join channel_info_daily f on e.channel=f.channel and e.dt=f.dt
|
|
|
left join video_info g on c.image_id=g.video_id
|
|
|
- left join campaign_info h on b.campaign_id = h.campaign_id
|
|
|
+ left join campaign_info h on a.campaign_id = h.campaign_id
|
|
|
where a.dt='{dt}' and c.is_video=1 and h.campaign_id is not null
|
|
|
and length (signature)>6
|
|
|
group by signature)
|
|
@@ -267,12 +264,11 @@ if __name__ == '__main__':
|
|
|
)
|
|
|
|
|
|
|
|
|
- for i in du.getDateLists(du.get_n_days(-495), du.get_n_days(0)):
|
|
|
+ for i in du.getDateLists(du.get_n_days(-360), du.get_n_days(0)):
|
|
|
print(i)
|
|
|
-
|
|
|
run(i)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
+ run(du.get_n_days(-3))
|