|
@@ -69,8 +69,8 @@ class AppBytedanceAccountBaseInfoDsD:
|
|
bei.company_name,
|
|
bei.company_name,
|
|
bei.dept_id,
|
|
bei.dept_id,
|
|
bei.dept_name,
|
|
bei.dept_name,
|
|
- (ifnull(t1.all_campaign_num, 0) + ifnull(t3.campain_num, 0)) as all_campaign_num,
|
|
|
|
- t3.campain_num new_campaign_num,
|
|
|
|
|
|
+ (ifnull(t1.all_campaign_num, 0) + ifnull(cam.campain_num, 0)) as all_campaign_num,
|
|
|
|
+ cam.campain_num new_campaign_num,
|
|
(ifnull(t1.all_ad_num, 0) + ifnull(t2.ad_num, 0)) as all_ad_num,
|
|
(ifnull(t1.all_ad_num, 0) + ifnull(t2.ad_num, 0)) as all_ad_num,
|
|
t2.ad_num new_ad_num,
|
|
t2.ad_num new_ad_num,
|
|
(ifnull(t1.all_video_num, 0) + ifnull(t3.day_num, 0)) as all_video_num,
|
|
(ifnull(t1.all_video_num, 0) + ifnull(t3.day_num, 0)) as all_video_num,
|
|
@@ -85,43 +85,43 @@ class AppBytedanceAccountBaseInfoDsD:
|
|
0 as trust_unit_num
|
|
0 as trust_unit_num
|
|
from (select *
|
|
from (select *
|
|
from `application`.`app_bytedance_account_base_info_d`
|
|
from `application`.`app_bytedance_account_base_info_d`
|
|
- where stat_date = date_sub({date_time}, INTERVAL 1 DAY)) t1
|
|
|
|
|
|
+ where stat_date = date_sub(20220627, INTERVAL 1 DAY)) t1
|
|
left join
|
|
left join
|
|
(select account_id, count(id) ad_num
|
|
(select account_id, count(id) ad_num
|
|
from `media_api`.bytedance_ad_get
|
|
from `media_api`.bytedance_ad_get
|
|
- where date_format(ad_create_time, '%Y%m%d') = {date_time}
|
|
|
|
|
|
+ where date_format(ad_create_time, '%Y%m%d') = 20220627
|
|
group by account_id) t2
|
|
group by account_id) t2
|
|
on t1.account_id = t2.account_id
|
|
on t1.account_id = t2.account_id
|
|
left join (select advertiser_id, count(campaign_id) campain_num
|
|
left join (select advertiser_id, count(campaign_id) campain_num
|
|
from media_api.bytedance_campaign_get
|
|
from media_api.bytedance_campaign_get
|
|
- where date_format(campaign_create_time, '%Y%m%d') = {date_time}
|
|
|
|
- group by advertiser_id) t3
|
|
|
|
- on t1.account_id = t3.advertiser_id
|
|
|
|
|
|
+ where date_format(campaign_create_time, '%Y%m%d') = 20220627
|
|
|
|
+ group by advertiser_id) cam
|
|
|
|
+ on t1.account_id = cam.advertiser_id
|
|
left join
|
|
left join
|
|
(select advertiser_id account_id, count(distinct signature) day_num
|
|
(select advertiser_id account_id, count(distinct signature) day_num
|
|
from `media_api`.bytedance_file_video_get
|
|
from `media_api`.bytedance_file_video_get
|
|
- where date_format(create_time, '%Y%m%d') = {date_time}
|
|
|
|
|
|
+ where date_format(create_time, '%Y%m%d') = 20220627
|
|
group by advertiser_id) t3
|
|
group by advertiser_id) t3
|
|
on t1.account_id = t3.account_id
|
|
on t1.account_id = t3.account_id
|
|
left join
|
|
left join
|
|
(select t2.account_id, count(distinct t1.material_id) new_eff_material
|
|
(select t2.account_id, count(distinct t1.material_id) new_eff_material
|
|
- from (select material_id from application.app_bytedance_material_info where effect_date = {date_time}) t1
|
|
|
|
|
|
+ from (select material_id from application.app_bytedance_material_info where effect_date = 20220627) t1
|
|
inner join
|
|
inner join
|
|
(select distinct advertiser_id account_id, signature
|
|
(select distinct advertiser_id account_id, signature
|
|
from `media_api`.bytedance_file_video_get
|
|
from `media_api`.bytedance_file_video_get
|
|
where date_format(create_time, '%Y%m%d') >=
|
|
where date_format(create_time, '%Y%m%d') >=
|
|
- date_sub({date_time}, INTERVAL 29 DAY)) t2
|
|
|
|
|
|
+ date_sub(20220627, INTERVAL 29 DAY)) t2
|
|
on t1.material_id = t2.signature
|
|
on t1.material_id = t2.signature
|
|
group by t2.account_id) t4
|
|
group by t2.account_id) t4
|
|
on t1.account_id = t4.account_id
|
|
on t1.account_id = t4.account_id
|
|
left join
|
|
left join
|
|
(select t2.account_id, count(distinct t1.material_id) new_hot_material
|
|
(select t2.account_id, count(distinct t1.material_id) new_hot_material
|
|
- from (select material_id from application.app_bytedance_material_info where faddish_date = {date_time}) t1
|
|
|
|
|
|
+ from (select material_id from application.app_bytedance_material_info where faddish_date = 20220627) t1
|
|
inner join
|
|
inner join
|
|
(select distinct advertiser_id account_id, signature
|
|
(select distinct advertiser_id account_id, signature
|
|
from `media_api`.bytedance_file_video_get
|
|
from `media_api`.bytedance_file_video_get
|
|
where date_format(create_time, '%Y%m%d') >=
|
|
where date_format(create_time, '%Y%m%d') >=
|
|
- date_sub({date_time}, INTERVAL 29 DAY)) t2
|
|
|
|
|
|
+ date_sub(20220627, INTERVAL 29 DAY)) t2
|
|
on t1.material_id = t2.signature
|
|
on t1.material_id = t2.signature
|
|
group by t2.account_id) t5
|
|
group by t2.account_id) t5
|
|
on t1.account_id = t5.account_id
|
|
on t1.account_id = t5.account_id
|
|
@@ -163,7 +163,7 @@ from (select *
|
|
where bei.account_id is not null
|
|
where bei.account_id is not null
|
|
union all
|
|
union all
|
|
select
|
|
select
|
|
- {date_time} stat_date,
|
|
|
|
|
|
+ 20220627 stat_date,
|
|
t1.account_id,
|
|
t1.account_id,
|
|
bei.account_name,
|
|
bei.account_name,
|
|
bei.project_id,
|
|
bei.project_id,
|
|
@@ -178,8 +178,8 @@ union all
|
|
bei.company_name,
|
|
bei.company_name,
|
|
bei.dept_id,
|
|
bei.dept_id,
|
|
bei.dept_name,
|
|
bei.dept_name,
|
|
- t3.campaign_num as all_campaign_num ,
|
|
|
|
- t3.campaign_num new_campaign_num,
|
|
|
|
|
|
+ cam.campaign_num as all_campaign_num ,
|
|
|
|
+ cam.campaign_num new_campaign_num,
|
|
t2.ad_num as all_ad_num,
|
|
t2.ad_num as all_ad_num,
|
|
t2.ad_num as new_ad_num,
|
|
t2.ad_num as new_ad_num,
|
|
t3.day_num as all_video_num,
|
|
t3.day_num as all_video_num,
|
|
@@ -195,34 +195,34 @@ union all
|
|
from
|
|
from
|
|
(select distinct account_id from `application`.`app_bytedance_account_base_info_d`) tt
|
|
(select distinct account_id from `application`.`app_bytedance_account_base_info_d`) tt
|
|
left join
|
|
left join
|
|
- (select distinct advertiser_id account_id,signature from `media_api`.bytedance_file_video_get where date_format(create_time,'%Y%m%d')={date_time}) t1
|
|
|
|
|
|
+ (select distinct advertiser_id account_id,signature from `media_api`.bytedance_file_video_get where date_format(create_time,'%Y%m%d')=20220627) t1
|
|
on tt.account_id=t1.account_id
|
|
on tt.account_id=t1.account_id
|
|
left join
|
|
left join
|
|
(select account_id,count(id) ad_num from `media_api`.bytedance_ad_get
|
|
(select account_id,count(id) ad_num from `media_api`.bytedance_ad_get
|
|
- where date_format(ad_create_time,'%Y%m%d')={date_time} group by account_id) t2
|
|
|
|
|
|
+ where date_format(ad_create_time,'%Y%m%d')=20220627 group by account_id) t2
|
|
on t1.account_id=t2.account_id
|
|
on t1.account_id=t2.account_id
|
|
left join
|
|
left join
|
|
(select advertiser_id,count(campaign_id) campaign_num from `media_api`.bytedance_campaign_get
|
|
(select advertiser_id,count(campaign_id) campaign_num from `media_api`.bytedance_campaign_get
|
|
- where date_format(campaign_create_time,'%Y%m%d')={date_time} group by advertiser_id) t3
|
|
|
|
- on t1.account_id=t3.advertiser_id
|
|
|
|
|
|
+ where date_format(campaign_create_time,'%Y%m%d')=20220627 group by advertiser_id) cam
|
|
|
|
+ on t1.account_id=cam.advertiser_id
|
|
left join
|
|
left join
|
|
(select advertiser_id account_id,count(distinct signature) day_num from `media_api`.bytedance_file_video_get
|
|
(select advertiser_id account_id,count(distinct signature) day_num from `media_api`.bytedance_file_video_get
|
|
- where date_format(create_time,'%Y%m%d')={date_time} group by advertiser_id) t3
|
|
|
|
|
|
+ where date_format(create_time,'%Y%m%d')=20220627 group by advertiser_id) t3
|
|
on t1.account_id=t3.account_id
|
|
on t1.account_id=t3.account_id
|
|
left join
|
|
left join
|
|
(select t2.account_id,count(distinct t1.material_id) new_eff_material from
|
|
(select t2.account_id,count(distinct t1.material_id) new_eff_material from
|
|
- (select material_id from application.app_bytedance_material_info where effect_date={date_time}) t1
|
|
|
|
|
|
+ (select material_id from application.app_bytedance_material_info where effect_date=20220627) t1
|
|
inner join
|
|
inner join
|
|
(select distinct advertiser_id account_id,signature from `media_api`.bytedance_file_video_get where date_format(create_time,'%Y%m%d')>=
|
|
(select distinct advertiser_id account_id,signature from `media_api`.bytedance_file_video_get where date_format(create_time,'%Y%m%d')>=
|
|
- date_sub({date_time},INTERVAL 29 DAY)) t2
|
|
|
|
|
|
+ date_sub(20220627,INTERVAL 29 DAY)) t2
|
|
on t1.material_id=t2.signature group by t2.account_id) t4
|
|
on t1.material_id=t2.signature group by t2.account_id) t4
|
|
on t1.account_id=t4.account_id
|
|
on t1.account_id=t4.account_id
|
|
left join
|
|
left join
|
|
(select t2.account_id,count(distinct t1.material_id) new_hot_material from
|
|
(select t2.account_id,count(distinct t1.material_id) new_hot_material from
|
|
- (select material_id from application.app_bytedance_material_info where faddish_date={date_time}) t1
|
|
|
|
|
|
+ (select material_id from application.app_bytedance_material_info where faddish_date=20220627) t1
|
|
inner join
|
|
inner join
|
|
(select distinct advertiser_id account_id,signature from `media_api`.bytedance_file_video_get where date_format(create_time,'%Y%m%d')>=
|
|
(select distinct advertiser_id account_id,signature from `media_api`.bytedance_file_video_get where date_format(create_time,'%Y%m%d')>=
|
|
- date_sub({date_time},INTERVAL 29 DAY)) t2
|
|
|
|
|
|
+ date_sub(20220627,INTERVAL 29 DAY)) t2
|
|
on t1.material_id=t2.signature group by t2.account_id) t5
|
|
on t1.material_id=t2.signature group by t2.account_id) t5
|
|
on t1.account_id=t5.account_id
|
|
on t1.account_id=t5.account_id
|
|
left join
|
|
left join
|
|
@@ -262,8 +262,8 @@ union all
|
|
) bei
|
|
) bei
|
|
ON t1.account_id = bei.account_id where tt.account_id is null and bei.account_id is not null
|
|
ON t1.account_id = bei.account_id where tt.account_id is null and bei.account_id is not null
|
|
group by t1.account_id;
|
|
group by t1.account_id;
|
|
-
|
|
|
|
""".format(date_time=self.date_time)
|
|
""".format(date_time=self.date_time)
|
|
|
|
+ print(sql)
|
|
TidbConn.upsert(conn=self.conn, sql_buff=sql)
|
|
TidbConn.upsert(conn=self.conn, sql_buff=sql)
|
|
self.conn.commit()
|
|
self.conn.commit()
|
|
TidbConn.conn_close(conn=self.conn)
|
|
TidbConn.conn_close(conn=self.conn)
|