Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
bi-report
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
data
bi-report
Commits
817b3b60
Commit
817b3b60
authored
Sep 07, 2020
by
魏艺敏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
push codes
parent
5cd586fc
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
84 additions
and
27 deletions
+84
-27
daily_operation.sql
pm/daily_operation/etl/daily_operation.sql
+4
-4
daily_operation.sql
pm/daily_operation/report/daily_operation.sql
+3
-3
daily_recommend_strategy.sql
pm/daily_recommend_strategy/etl/daily_recommend_strategy.sql
+73
-19
home_recommend_strategy.sql
...ily_recommend_strategy/report/home_recommend_strategy.sql
+4
-1
No files found.
pm/daily_operation/etl/daily_operation.sql
View file @
817b3b60
...
...
@@ -81,7 +81,7 @@ INSERT OVERWRITE TABLE pm.tl_pm_channel_d PARTITION (PARTITION_DAY = ${partition
INSERT
OVERWRITE
TABLE
pm
.
tl_pm_operation_d
PARTITION
(
PARTITION_DAY
=
${
partition_day
}
)
SELECT
t
1
.
partition_date
as
day_id
SELECT
t
concat_ws
(
'-'
,
substr
(
t1
.
partition_date
,
1
,
4
),
substr
(
t1
.
partition_date
,
5
,
2
),
substr
(
t1
.
partition_date
,
7
,
2
))
as
day_id
,
t1
.
device_os_type
as
device_os_type
,
t1
.
device_type
as
active_type
,
t1
.
channel
as
channel
...
...
@@ -509,8 +509,8 @@ LEFT JOIN
AND
page_code
=
'home'
AND
is_exposure
=
'1'
AND
tab_code
=
'精选'
AND
(
params
[
'transaction_type'
]
in
(
'-1'
,
'smr'
,
'hotspot'
,
'pgc'
,
'newdata'
,
'hotspot_feed'
,
'aistragegy'
,
'excestragegy'
,
'fixedstragegy'
,
'fixedstragegy_video
'
)
or
params
[
'transaction_type'
]
like
'%ctr'
or
params
[
'transaction_type'
]
like
'%cvr'
)
AND
(
transaction_type
in
(
'-1'
,
'smr'
,
'hotspot'
,
'pgc'
,
'newdata'
,
'hotspot_feed'
,
'aistragegy'
,
'excestragegy'
,
'fixedstragegy'
,
'fixedstragegy_video'
,
'deeplink_strategy
'
)
or
transaction_type
like
'%ctr'
or
transaction_type
like
'%cvr'
)
AND
action
in
(
'page_precise_exposure'
,
'home_choiceness_card_exposure'
)
--7745版本action改为page_precise_exposure
AND
card_content_type
in
(
'user_post'
,
'diary'
,
'qa'
,
'answer'
)
)
t1
...
...
@@ -589,7 +589,7 @@ LEFT JOIN
AND
action
=
'on_click_card'
AND
page_code
=
'home'
AND
tab_code
=
'精选'
AND
(
transaction_type
in
(
'-1'
,
'smr'
,
'hotspot'
,
'pgc'
,
'newdata'
,
'hotspot_feed'
,
'aistragegy'
,
'excestragegy'
,
'fixedstragegy'
,
'fixedstragegy_video'
)
AND
(
transaction_type
in
(
'-1'
,
'smr'
,
'hotspot'
,
'pgc'
,
'newdata'
,
'hotspot_feed'
,
'aistragegy'
,
'excestragegy'
,
'fixedstragegy'
,
'fixedstragegy_video'
,
'deeplink_strategy'
)
or
transaction_type
like
'%ctr'
or
transaction_type
like
'%cvr'
)
AND
card_content_type
in
(
'diary'
,
'user_post'
,
'qa'
,
'answer'
)
)
t1
...
...
pm/daily_operation/report/daily_operation.sql
View file @
817b3b60
SELECT
FROM_UNIXTIME
(
UNIX_TIMESTAMP
(
day_id
,
'yyyymmdd'
),
'yyyy-mm-dd'
)
`日期`
SELECT
day_id
`日期`
,
device_os_type
`系统`
,
active_type
`新老`
,
channel
`渠道`
...
...
@@ -70,7 +70,7 @@ SELECT FROM_UNIXTIME(UNIX_TIMESTAMP(day_id,'yyyymmdd'),'yyyy-mm-dd') `日期`
,
nvl
(
wel_second_pv_in_neirongPV
,
0
)
as
`来自内容页的商业二跳/内容pv`
,
nvl
(
neirong_second_pv_in_neirongPV
,
0
)
as
`来自内容页的内容二跳/内容pv`
FROM
pm
.
tl_pm_operation_d
where
((
partition_day
=
'20200
824'
and
day_id
<=
'20200726
'
)
or
(
partition_day
<
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
and
partition_day
>
'20200
824
'
and
day_id
=
regexp_replace
(
date_sub
(
FROM_UNIXTIME
(
UNIX_TIMESTAMP
(
partition_day
,
'yyyymmdd'
),
'yyyy-mm-dd'
),
29
),
'-'
,
''
))
where
((
partition_day
=
'20200
906'
and
day_id
<=
'20200808
'
)
or
(
partition_day
<
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
and
partition_day
>
'20200
906
'
and
day_id
=
regexp_replace
(
date_sub
(
FROM_UNIXTIME
(
UNIX_TIMESTAMP
(
partition_day
,
'yyyymmdd'
),
'yyyy-mm-dd'
),
29
),
'-'
,
''
))
or
(
partition_day
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
and
day_id
>=
regexp_replace
(
date_sub
(
current_date
,
30
),
'-'
,
''
)))
order
by
`日期`
,
`系统`
,
`新老`
,
`渠道`
pm/daily_recommend_strategy/etl/daily_recommend_strategy.sql
View file @
817b3b60
...
...
@@ -20,6 +20,7 @@ SELECT
t2
.
recommend_type
as
recommend_type
,
NVL
(
sum
(
t3
.
session_pv
),
0
)
as
card_click
,
NVL
(
sum
(
t2
.
session_pv
),
0
)
as
card_exposure
,
NVL
(
sum
(
t2
.
session_pv
),
0
)
as
card_exposure
,
NVL
(
round
(
sum
(
page_stay
)
/
count
(
distinct
t4
.
cl_id
)
/
60
,
2
),
0
)
as
avg_page_stay
,
NVL
(
sum
(
navbar_pv
),
0
)
as
navbar_search
,
NVL
(
sum
(
highlight_pv
),
0
)
as
highlight_word
,
...
...
@@ -28,7 +29,10 @@ SELECT
NVL
(
sum
(
recom_content_pv
),
0
)
as
recommend_content_card
,
NULL
as
recommend_special_card
,
NVL
(
sum
(
referral_pv
),
0
)
as
transfer_card
,
NVL
(
sum
(
video_pv
),
0
)
as
video_consultation
NVL
(
sum
(
video_pv
),
0
)
as
video_consultation
,
NVL
(
sum
(
post_pv
),
0
)
as
total_post_pv
,
NVL
(
sum
(
post_click_pv
),
0
)
as
post_click_pv
FROM
(
SELECT
partition_date
...
...
@@ -66,12 +70,14 @@ FROM
WHEN
transaction_type
like
'%ctr'
THEN
array
(
'ctr预估'
,
'合计'
)
WHEN
transaction_type
like
'%cvr'
THEN
array
(
'cvr预估'
,
'合计'
)
WHEN
transaction_type
in
(
'-1'
,
'smr'
)
THEN
array
(
'smr'
,
'合计'
)
when
transaction_type
in
(
'pgc'
,
'hotspot'
)
then
array
(
'热点卡片'
,
'合计'
)
when
transaction_type
in
(
'pgc'
,
'hotspot'
)
then
array
(
'热点卡片'
)
when
transaction_type
in
(
'newdata'
)
then
array
(
'保量卡片'
)
when
transaction_type
in
(
'hotspot_feed'
)
then
array
(
'hotspot_feed'
,
'合计'
)
when
transaction_type
in
(
'aistragegy'
)
then
array
(
'新用户AI帖优先'
)
when
transaction_type
in
(
'excestragegy'
)
then
array
(
'新用户精华帖优先'
)
when
transaction_type
in
(
'deeplink_strategy'
)
then
array
(
'deeplink策略'
)
when
transaction_type
in
(
'aistragegy'
)
then
array
(
'新用户AI帖优先'
,
'合计'
)
when
transaction_type
in
(
'excestragegy'
)
then
array
(
'新用户精华帖优先'
,
'合计'
)
when
transaction_type
in
(
'FIXEDSTRATEGY'
)
then
array
(
'新氧新用户策略一'
,
'合计'
)
when
transaction_type
in
(
'FIXEDSTRATEGY_VIDEO'
)
then
array
(
'新氧新用户策略二'
,
'合计'
)
when
transaction_type
in
(
'deeplink_strategy'
)
then
array
(
'deeplink策略'
,
'合计'
)
end
AS
recommend_type
,
card_id
,
app_session_id
...
...
@@ -81,7 +87,7 @@ FROM
AND
is_exposure
=
'1'
----精准曝光
AND
page_name
=
'home'
AND
tab_name
=
'精选'
AND
(
transaction_type
in
(
'-1'
,
'smr'
,
'hotspot'
,
'pgc'
,
'newdata'
,
'hotspot_feed'
,
'aistragegy'
,
'excestragegy'
,
'deeplink_strategy'
)
AND
(
transaction_type
in
(
'-1'
,
'smr'
,
'hotspot'
,
'pgc'
,
'newdata'
,
'hotspot_feed'
,
'aistragegy'
,
'excestragegy'
,
'
FIXEDSTRATEGY'
,
'FIXEDSTRATEGY_VIDEO'
,
'
deeplink_strategy'
)
or
transaction_type
like
'%ctr'
or
transaction_type
like
'%cvr'
)
AND
card_content_type
in
(
'qa'
,
'diary'
,
'user_post'
,
'answer'
,
'special_pool'
)
group
by
partition_date
,
...
...
@@ -92,12 +98,14 @@ FROM
WHEN
transaction_type
like
'%ctr'
THEN
array
(
'ctr预估'
,
'合计'
)
WHEN
transaction_type
like
'%cvr'
THEN
array
(
'cvr预估'
,
'合计'
)
WHEN
transaction_type
in
(
'-1'
,
'smr'
)
THEN
array
(
'smr'
,
'合计'
)
when
transaction_type
in
(
'pgc'
,
'hotspot'
)
then
array
(
'热点卡片'
,
'合计'
)
when
transaction_type
in
(
'pgc'
,
'hotspot'
)
then
array
(
'热点卡片'
)
when
transaction_type
in
(
'newdata'
)
then
array
(
'保量卡片'
)
when
transaction_type
in
(
'hotspot_feed'
)
then
array
(
'hotspot_feed'
,
'合计'
)
when
transaction_type
in
(
'aistragegy'
)
then
array
(
'新用户AI帖优先'
)
when
transaction_type
in
(
'excestragegy'
)
then
array
(
'新用户精华帖优先'
)
when
transaction_type
in
(
'deeplink_strategy'
)
then
array
(
'deeplink策略'
)
end
,
when
transaction_type
in
(
'aistragegy'
)
then
array
(
'新用户AI帖优先'
,
'合计'
)
when
transaction_type
in
(
'excestragegy'
)
then
array
(
'新用户精华帖优先'
,
'合计'
)
when
transaction_type
in
(
'FIXEDSTRATEGY'
)
then
array
(
'新氧新用户策略一'
,
'合计'
)
when
transaction_type
in
(
'FIXEDSTRATEGY_VIDEO'
)
then
array
(
'新氧新用户策略二'
,
'合计'
)
when
transaction_type
in
(
'deeplink_strategy'
)
then
array
(
'deeplink策略'
,
'合计'
)
end
,
card_id
,
app_session_id
)
a
...
...
@@ -123,12 +131,14 @@ FROM
WHEN
params
[
'transaction_type'
]
like
'%ctr'
THEN
array
(
'ctr预估'
,
'合计'
)
WHEN
params
[
'transaction_type'
]
like
'%cvr'
THEN
array
(
'cvr预估'
,
'合计'
)
WHEN
params
[
'transaction_type'
]
in
(
'-1'
,
'smr'
)
THEN
array
(
'smr'
,
'合计'
)
when
params
[
'transaction_type'
]
in
(
'pgc'
,
'hotspot'
)
then
array
(
'热点卡片'
,
'合计'
)
when
params
[
'transaction_type'
]
in
(
'pgc'
,
'hotspot'
)
then
array
(
'热点卡片'
)
when
params
[
'transaction_type'
]
in
(
'newdata'
)
then
array
(
'保量卡片'
)
when
params
[
'transaction_type'
]
in
(
'hotspot_feed'
)
then
array
(
'hotspot_feed'
,
'合计'
)
when
params
[
'transaction_type'
]
in
(
'aistragegy'
)
then
array
(
'新用户AI帖优先'
)
when
params
[
'transaction_type'
]
in
(
'excestragegy'
)
then
array
(
'新用户精华帖优先'
)
when
params
[
'transaction_type'
]
in
(
'deeplink_strategy'
)
then
array
(
'deeplink策略'
)
when
params
[
'transaction_type'
]
in
(
'aistragegy'
)
then
array
(
'新用户AI帖优先'
,
'合计'
)
when
params
[
'transaction_type'
]
in
(
'excestragegy'
)
then
array
(
'新用户精华帖优先'
,
'合计'
)
when
params
[
'transaction_type'
]
in
(
'FIXEDSTRATEGY'
)
then
array
(
'新氧新用户策略一'
,
'合计'
)
when
params
[
'transaction_type'
]
in
(
'FIXEDSTRATEGY_VIDEO'
)
then
array
(
'新氧新用户策略二'
,
'合计'
)
when
params
[
'transaction_type'
]
in
(
'deeplink_strategy'
)
then
array
(
'deeplink策略'
,
'合计'
)
end
AS
recommend_type
,
params
[
'card_id'
]
as
card_id
,
app_session_id
...
...
@@ -137,7 +147,7 @@ FROM
AND
action
=
'on_click_card'
AND
params
[
'page_name'
]
=
'home'
AND
params
[
'tab_name'
]
=
'精选'
AND
(
params
[
'transaction_type'
]
in
(
'-1'
,
'smr'
,
'hotspot'
,
'pgc'
,
'newdata'
,
'hotspot_feed'
,
'aistragegy'
,
'excestragegy'
,
'deeplink_strategy'
)
AND
(
params
[
'transaction_type'
]
in
(
'-1'
,
'smr'
,
'hotspot'
,
'pgc'
,
'newdata'
,
'hotspot_feed'
,
'aistragegy'
,
'excestragegy'
,
'
FIXEDSTRATEGY'
,
'FIXEDSTRATEGY_VIDEO'
,
'
deeplink_strategy'
)
or
params
[
'transaction_type'
]
like
'%ctr'
or
params
[
'transaction_type'
]
like
'%cvr'
)
AND
params
[
'card_content_type'
]
in
(
'qa'
,
'diary'
,
'user_post'
,
'answer'
,
'special_pool'
)
GROUP
BY
partition_date
,
...
...
@@ -148,12 +158,14 @@ FROM
WHEN
params
[
'transaction_type'
]
like
'%ctr'
THEN
array
(
'ctr预估'
,
'合计'
)
WHEN
params
[
'transaction_type'
]
like
'%cvr'
THEN
array
(
'cvr预估'
,
'合计'
)
WHEN
params
[
'transaction_type'
]
in
(
'-1'
,
'smr'
)
THEN
array
(
'smr'
,
'合计'
)
when
params
[
'transaction_type'
]
in
(
'pgc'
,
'hotspot'
)
then
array
(
'热点卡片'
,
'合计'
)
when
params
[
'transaction_type'
]
in
(
'pgc'
,
'hotspot'
)
then
array
(
'热点卡片'
)
when
params
[
'transaction_type'
]
in
(
'newdata'
)
then
array
(
'保量卡片'
)
when
params
[
'transaction_type'
]
in
(
'hotspot_feed'
)
then
array
(
'hotspot_feed'
,
'合计'
)
when
params
[
'transaction_type'
]
in
(
'aistragegy'
)
then
array
(
'新用户AI帖优先'
)
when
params
[
'transaction_type'
]
in
(
'excestragegy'
)
then
array
(
'新用户精华帖优先'
)
when
params
[
'transaction_type'
]
in
(
'deeplink_strategy'
)
then
array
(
'deeplink策略'
)
end
,
when
params
[
'transaction_type'
]
in
(
'aistragegy'
)
then
array
(
'新用户AI帖优先'
,
'合计'
)
when
params
[
'transaction_type'
]
in
(
'excestragegy'
)
then
array
(
'新用户精华帖优先'
,
'合计'
)
when
params
[
'transaction_type'
]
in
(
'FIXEDSTRATEGY'
)
then
array
(
'新氧新用户策略一'
,
'合计'
)
when
params
[
'transaction_type'
]
in
(
'FIXEDSTRATEGY_VIDEO'
)
then
array
(
'新氧新用户策略二'
,
'合计'
)
when
params
[
'transaction_type'
]
in
(
'deeplink_strategy'
)
then
array
(
'deeplink策略'
,
'合计'
)
end
,
params
[
'card_id'
],
app_session_id
)
a
...
...
@@ -476,6 +488,48 @@ FROM
and
t11
.
business_id
=
t3
.
card_id
and
t11
.
page_name
=
t3
.
card_content_type
LEFT
JOIN
(
--从帖子页到帖子页
SELECT
partition_date
,
cl_id
,
params
[
'referrer_id'
]
as
business_id
,
case
when
page_name
in
(
'post_detail'
,
'user_post_detail'
,
'doctor_post_detail'
)
then
'user_post'
else
null
end
as
page_name
,
count
(
distinct
params
[
'business_id'
],
app_session_id
)
as
post_pv
FROM
online
.
bl_hdfs_maidian_updates
WHERE
partition_date
=
regexp_replace
(
DATE_SUB
(
current_date
,
1
)
,
'-'
,
''
)
AND
action
=
'page_view'
AND
page_name
IN
(
'post_detail'
,
'user_post_detail'
,
'doctor_post_detail'
,
'custom_special'
)
AND
(
json_split
(
params
[
'referrer_link'
])[
size
(
json_split
(
params
[
'referrer_link'
]))
-
1
]
IN
(
'post_detail'
,
'user_post_detail'
,
'doctor_post_detail'
)
and
json_split
(
params
[
'referrer_link'
])[
size
(
json_split
(
params
[
'referrer_link'
]))
-
2
]
=
'home'
)
group
by
partition_date
,
cl_id
,
params
[
'referrer_id'
],
case
when
page_name
in
(
'post_detail'
,
'user_post_detail'
,
'doctor_post_detail'
)
then
'user_post'
else
null
end
)
t12
on
t12
.
partition_date
=
t3
.
partition_date
and
t12
.
cl_id
=
t3
.
cl_id
and
t12
.
business_id
=
t3
.
card_id
and
t12
.
page_name
=
t3
.
card_content_type
left
join
(
--在帖子页点击帖子
SELECT
partition_date
,
cl_id
,
params
[
'business_id'
]
as
business_id
,
case
when
page_name
in
(
'post_detail'
,
'user_post_detail'
,
'doctor_post_detail'
)
then
'user_post'
else
null
end
as
page_name
,
count
(
distinct
params
[
'card_id'
],
app_session_id
)
as
post_click_pv
FROM
online
.
bl_hdfs_maidian_updates
WHERE
partition_date
=
regexp_replace
(
DATE_SUB
(
current_date
,
1
)
,
'-'
,
''
)
AND
action
=
'on_click_card'
and
params
[
'card_content_type'
]
in
(
'user_post'
)
AND
page_name
IN
(
'post_detail'
,
'user_post_detail'
,
'doctor_post_detail'
)
AND
(
referrer
=
'home'
or
(
params
[
'referrer_link'
]
like
'%[%'
and
json_split
(
params
[
'referrer_link'
])[
size
(
json_split
(
params
[
'referrer_link'
]))
-
1
]
=
'home'
))
group
by
partition_date
,
cl_id
,
params
[
'business_id'
],
case
when
page_name
in
(
'post_detail'
,
'user_post_detail'
,
'doctor_post_detail'
)
then
'user_post'
else
null
end
)
t13
on
t13
.
partition_date
=
t3
.
partition_date
and
t13
.
cl_id
=
t3
.
cl_id
and
t13
.
business_id
=
t3
.
card_id
and
t13
.
page_name
=
t3
.
card_content_type
LEFT
JOIN
(
select
distinct
device_id
from
ml
.
ml_d_ct_dv_devicespam_d
--去除机构刷单设备,即作弊设备(浏览和曝光事件去除)
...
...
pm/daily_recommend_strategy/report/home_recommend_strategy.sql
View file @
817b3b60
...
...
@@ -18,6 +18,8 @@ SELECT
recommend_content_card
as
`来自I的推荐内容点击pv`
,
-- '未配置' as `来自I的推荐专题点击pv`,
transfer_card
as
`来自I的转诊点击pv`
,
video_consultation
as
`来自I的视频面诊点击pv`
FROM
pm
.
tl_pm_recommend_strategy_d
video_consultation
as
`来自I的视频面诊点击pv`
if
(
total_post_pv
-
post_click_pv
>=
0
,
total_post_pv
-
post_click_pv
,
0
)
as
`帖子页链接点击pv(近似值)`
FROM
pm
.
tl_pm_recommend_strategy_d
WHERE
partition_day
>=
'20200824'
and
partition_day
<=
regexp_replace
(
DATE_SUB
(
current_date
,
1
)
,
'-'
,
''
)
order
by
`日期`
desc
,
`设备类型`
,
`活跃类型`
,
`卡片类型`
,
`推荐类型`
;
\ No newline at end of file
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