Commit bcfa4ecb authored by litaolemo's avatar litaolemo

update

parent d9608044
......@@ -80,17 +80,17 @@ SELECT
,all_search_click_pv_724
,all_search_uv
,all_search_pv
,if(dau <> 0 ,concat(cast((all_search_uv/dau)*100 as decimal(18,2)),'%') , '-')
,if(all_search_uv <> 0 ,concat(cast((all_search_pv/all_search_uv) as decimal(18,2)),'') , '-')
,if(search_home_pv <> 0 ,concat(cast((all_search_pv/search_home_pv)*100 as decimal(18,2)),'%') , '-')
,if(sug_out_pv_726 <> 0 ,concat(cast((sug_search_pv_726/sug_out_pv_726)*100 as decimal(18,2)),'%') , '-')
,if(dau <> 0 ,cast((all_search_uv/dau) as decimal(18,2)) , 0)
,if(all_search_uv <> 0 ,concat(cast((all_search_pv/all_search_uv) as decimal(18,4)),'') , 0)
,if(search_home_pv <> 0 ,cast((all_search_pv/search_home_pv) as decimal(18,4)) , 0)
,if(sug_out_pv_726 <> 0 ,cast((sug_search_pv_726/sug_out_pv_726) as decimal(18,4)) , 0)
,NVL(referrer_search_hexin_pv,0)
,NVL(referrer_search_welfare_pv,0)
,if(all_search_uv <> 0 ,concat(cast((referrer_search_hexin_pv/dau) as decimal(18,2)),'') , '-')
,if(all_search_uv <> 0 ,concat(cast((referrer_search_neirong_pv/dau) as decimal(18,2)),'') , '-')
,if(referrer_search_hexin_pv <> 0 ,concat(cast((search_hexin_two_pv/dau)*100 as decimal(18,2)),'%') , '-')
,if(referrer_search_neirong_pv <> 0 ,concat(cast((search_neirong_two_pv/dau)*100 as decimal(18,2)),'%') , '-')
,if(referrer_search_neirong_uv_1000 <> 0 ,concat(cast((referrer_search_neirong_pagestay/dau) as decimal(18,2)),'') , '-')
,if(all_search_uv <> 0 ,concat(cast((referrer_search_hexin_pv/dau) as decimal(18,2)),'') , 0)
,if(all_search_uv <> 0 ,concat(cast((referrer_search_neirong_pv/dau) as decimal(18,2)),'') , 0)
,if(referrer_search_hexin_pv <> 0 ,cast((search_hexin_two_pv/dau)*100 as decimal(18,4)) , 0)
,if(referrer_search_neirong_pv <> 0 ,cast((search_neirong_two_pv/dau)*100 as decimal(18,4)) , 0)
,if(referrer_search_neirong_uv_1000 <> 0 ,concat(cast((referrer_search_neirong_pagestay/dau) as decimal(18,4)),'') , 0)
,NVL(referrer_search_neirong_pv,0)
,NVL(search_hexin_two_pv,0)
,NVL(search_neirong_two_pv,0)
......@@ -543,25 +543,42 @@ FROM
sql_res = device_df.collect()
for res in sql_res:
print(res)
# device_type = res.device_type
# active_type = res.active_type
# channel_type = res.channel_type
# core_pv_division_uv = res.core_pv_division_uv
# pv_division_uv = res.pv_division_uv
# pid = hashlib.md5(
# (today_str + device_type + active_type + channel_type).encode("utf8")).hexdigest()
# instert_sql = """replace into search_strategy_d(
# day_id,device_type,active_type,channel_type,core_pv_division_uv,pv_division_uv,pid
# ) VALUES('{day_id}','{device_type}','{active_type}','{channel_type}',{core_pv_division_uv},{pv_division_uv},'{pid}');""".format(
# day_id=today_str, device_type=device_type,
# active_type=active_type, channel_type=channel_type, core_pv_division_uv=core_pv_division_uv,
# pv_division_uv=pv_division_uv, pid=pid
#
# )
# print(instert_sql)
# # cursor.execute("set names 'UTF8'")
# res = cursor.execute(instert_sql)
# db.commit()
# print(res)
# db.close()
partition_date = res.partition_date
device_os_type = res.device_os_type
active_type = res.device_os_type
channel = res.channel
dau = res.dau
all_search_click_uv_724 = res.all_search_click_uv_724
all_search_click_pv_724 = res.all_search_click_pv_724
all_search_uv = res.all_search_uv
all_search_pv = res.all_search_pv
completed_user_rate = res.completed_user_rate
per_user_search_count = res.per_user_search_count
search_success_rate = res.search_success_rate
sug_uesd_rate = res.sug_uesd_rate
referrer_search_hexin_pv = res.referrer_search_hexin_pv
referrer_search_welfare_pv = res.referrer_search_welfare_pv
search_core_pv_div_dau = res.search_core_pv_div_dau
search_core_two_div_dau = res.search_core_two_div_dau
search_neirong_two_div_dau = res.search_neirong_two_div_dau
search_neirong_per_duration = res.search_neirong_per_duration
referrer_search_neirong_pv = res.referrer_search_neirong_pv
pid = hashlib.md5((partition_date + device_os_type + active_type + channel).encode("utf8")).hexdigest()
instert_sql = """replace into core_indicators_monitoring(
partition_date,device_os_type,active_type,channel,dau,all_search_click_uv_724,all_search_click_pv_724,all_search_uv,all_search_pv,completed_user_rate,per_user_search_count,
search_success_rate,sug_uesd_rate,referrer_search_hexin_pv,referrer_search_welfare_pv,search_core_pv_div_dau,search_core_two_div_dau,search_neirong_two_div_dau,search_neirong_per_duration,referrer_search_neirong_pv,pid
) VALUES('{partition_date}','{device_os_type}','{active_type}','{channel}',{dau},{all_search_click_uv_724},{all_search_click_pv_724},{all_search_uv},{all_search_pv},{completed_user_rate},{per_user_search_count},
{search_success_rate},{sug_uesd_rate},{referrer_search_hexin_pv},{referrer_search_welfare_pv},{search_core_pv_div_dau},{search_core_two_div_dau},{search_neirong_two_div_dau},{search_neirong_per_duration},{referrer_search_neirong_pv},'{pid}');""".format(
partition_date=partition_date, device_os_type=device_os_type,
active_type=active_type, channel=channel, dau=dau,
all_search_click_uv_724=all_search_click_uv_724,all_search_click_pv_724=all_search_click_uv_724,all_search_uv=all_search_uv,all_search_pv=all_search_pv,completed_user_rate=completed_user_rate,per_user_search_count=per_user_search_count,
search_success_rate=search_success_rate,sug_uesd_rate=sug_uesd_rate,referrer_search_hexin_pv=referrer_search_hexin_pv,referrer_search_welfare_pv=referrer_search_welfare_pv,search_core_pv_div_dau=search_core_pv_div_dau,search_core_two_div_dau=search_core_two_div_dau,search_neirong_two_div_dau=search_neirong_two_div_dau,search_neirong_per_duration=search_neirong_per_duration,referrer_search_neirong_pv=referrer_search_neirong_pv,pid=pid
)
print(instert_sql)
# cursor.execute("set names 'UTF8'")
res = cursor.execute(instert_sql)
db.commit()
print(res)
db.close()
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment