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
152b82f6
Commit
152b82f6
authored
May 21, 2021
by
宋柯
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
首页指标
parent
d543b0fb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
4 deletions
+11
-4
home_feed_recommend_strategy_d.py
task/home_feed_recommend_strategy_d.py
+11
-4
No files found.
task/home_feed_recommend_strategy_d.py
View file @
152b82f6
...
...
@@ -62,6 +62,7 @@ HIVE_SQL = """
SELECT partition_date as `日期`
,a.device_os_type as `设备类型`
,b.active_type as `活跃类型`
,c.rank_type as `排序类型`
,d.card_content_type as `卡片类型`
,e.is_cpc as `是否cpc`
,sum(exp_pv) as `卡片曝光pv`
...
...
@@ -72,6 +73,7 @@ FROM
,array(active_type,'合计') as active_type
,array(t2.card_content_type,'合计') as card_content_type
,array(t2.is_cpc,'合计') as is_cpc
,array(t1.rank_type,'合计') as rank_type
,t1.device_id
,sum(exp_pv) as exp_pv
,sum(click_pv) as click_pv
...
...
@@ -82,10 +84,12 @@ FROM
,device_id
,device_os_type
,active_type
,rank_type
FROM
( --渠道,新老
SELECT partition_date
,device_id
,case when substr(md5('androidid_1aefc7584e57983e'),-1) in ('0','1', '2', '3', '4', '5', '6', '7') then 'lr' else 'smr' end as rank_type
,device_os_type
,CASE WHEN active_type = '4' THEN '老活' when active_type in ('1','2') then '新增' END as active_type
FROM online.ml_device_day_active_status
...
...
@@ -184,11 +188,13 @@ FROM
)t
lateral view explode(t.device_os_type ) a as device_os_type
lateral view explode(t.active_type ) b as active_type
lateral view explode(t.rank_type ) c as rank_type
lateral view explode(t.card_content_type ) d as card_content_type
lateral view explode(t.is_cpc ) e as is_cpc
group by partition_date
,a.device_os_type
,b.active_type
,c.rank_type
,d.card_content_type
,e.is_cpc
"""
.
format
(
START_PARTITION_DATE
,
START_PARTITION_DATE
,
START_PARTITION_DATE
)
...
...
@@ -204,18 +210,19 @@ print(pandas_df)
for
row
in
pandas_df
.
iterrows
():
partition_date
=
row
[
1
][
'日期'
]
device_os_type
=
row
[
1
][
'设备类型'
]
rank_type
=
row
[
1
][
'排序类型'
]
active_type
=
row
[
1
][
'活跃类型'
]
card_content_type
=
row
[
1
][
'卡片类型'
]
is_cpc
=
row
[
1
][
'是否cpc'
]
exp_pv
=
row
[
1
][
'卡片曝光pv'
]
click_pv
=
row
[
1
][
'卡片点击pv'
]
ctr
=
row
[
1
][
'卡片ctr'
]
pid
=
hashlib
.
md5
((
partition_date
+
device_os_type
+
active_type
+
card_content_type
+
is_cpc
)
.
encode
(
"utf8"
))
.
hexdigest
()
pid
=
hashlib
.
md5
((
partition_date
+
device_os_type
+
rank_type
+
active_type
+
card_content_type
+
is_cpc
)
.
encode
(
"utf8"
))
.
hexdigest
()
instert_sql
=
"""replace into home_feed_recommend_strategy_d(
partition_date,device_os_type,active_type,card_content_type,is_cpc,exp_pv,click_pv,ctr,pid
) VALUES('{partition_date}','{device_os_type}','{active_type}','{card_content_type}','{is_cpc}',{exp_pv},{click_pv},
partition_date,device_os_type,
rank_type,
active_type,card_content_type,is_cpc,exp_pv,click_pv,ctr,pid
) VALUES('{partition_date}','{device_os_type}','{
rank_type}','{
active_type}','{card_content_type}','{is_cpc}',{exp_pv},{click_pv},
{ctr},'{pid}');"""
.
format
(
partition_date
=
partition_date
,
device_os_type
=
device_os_type
,
active_type
=
active_type
,
card_content_type
=
card_content_type
,
partition_date
=
partition_date
,
device_os_type
=
device_os_type
,
rank_type
=
rank_type
,
active_type
=
active_type
,
card_content_type
=
card_content_type
,
is_cpc
=
is_cpc
,
exp_pv
=
exp_pv
,
click_pv
=
click_pv
,
ctr
=
ctr
,
pid
=
pid
)
print
(
instert_sql
)
...
...
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