Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
M
meta_base_code
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
宋柯
meta_base_code
Commits
b66ac0cb
Commit
b66ac0cb
authored
Aug 24, 2020
by
litaolemo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
eedc308c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
8 deletions
+8
-8
search_strategy_d.py
task/search_strategy_d.py
+8
-8
No files found.
task/search_strategy_d.py
View file @
b66ac0cb
...
...
@@ -78,8 +78,8 @@ for t in range(0, task_days):
,t3.channel as channel_type
,NVL(t3.search_pv,0) as 1_pv
,NVL(t3.search_uv,0) as 1_uv
,NVL(t4.hexin_card_click_pv,0) as
1_
search_core_pv
,NVL(t4.neirong_card_click_pv,0) as
1_
search_pv
,NVL(t4.hexin_card_click_pv,0) as search_core_pv
,NVL(t4.neirong_card_click_pv,0) as search_pv
FROM
(
SELECT query,active_type,device_os_type,channel,search_pv,search_uv
...
...
@@ -261,8 +261,8 @@ for t in range(0, task_days):
collects_sql
=
"""
SELECT device_type,active_type,channel_type,if(NVL(sum(1_uv),0) <> 0 ,concat((NVL(sum(
1_
search_core_pv),0)/NVL(sum(1_uv),0)) as decimal(18,4)) , 0) as 1_core_pv_division_uv
,if(NVL(sum(1_uv),0) <> 0 ,concat((NVL(sum(1_search_pv),0)/NVL(sum(1_uv),0)) as decimal(18,4)) , 0) as
1_
pv_division_uv
SELECT device_type,active_type,channel_type,if(NVL(sum(1_uv),0) <> 0 ,concat((NVL(sum(search_core_pv),0)/NVL(sum(1_uv),0)) as decimal(18,4)) , 0) as 1_core_pv_division_uv
,if(NVL(sum(1_uv),0) <> 0 ,concat((NVL(sum(1_search_pv),0)/NVL(sum(1_uv),0)) as decimal(18,4)) , 0) as pv_division_uv
FROM data_table GROUP BY device_type,active_type,channel_type
"""
finnal_df
=
spark
.
sql
(
collects_sql
)
...
...
@@ -274,13 +274,13 @@ for t in range(0, task_days):
device_type
=
res
.
device_type
active_type
=
res
.
active_type
channel_type
=
res
.
channel_type
core_pv_division_uv
=
res
[
"1_core_pv_division_uv"
]
pv_division_uv
=
res
[
"1_pv_division_uv"
]
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,
1_core_pv_division_uv,1_
pv_division_uv
) VALUES('{day_id}','{device_type}','{active_type}','{channel_type}',
'{core_pv_division_uv}',{pv_division_uv}
);"""
.
format
(
day_id,device_type,active_type,channel_type,
core_pv_division_uv,
pv_division_uv
) 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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment