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
4e8450c7
Commit
4e8450c7
authored
Nov 03, 2020
by
魏艺敏
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'weiyimin' into 'master'
Weiyimin See merge request
!93
parents
a22d8aae
70774155
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
461 additions
and
11 deletions
+461
-11
daily_recommend_strategy.sql
pm/daily_recommend_strategy/etl/daily_recommend_strategy.sql
+1
-1
en-cn.properties
pm/daily_userpost/en-cn.properties
+8
-5
create_userpost_old_v3.sql
pm/daily_userpost/etl/create_userpost_old_v3.sql
+70
-0
create_userpost_v2.sql
pm/daily_userpost/etl/create_userpost_v2.sql
+1
-1
daily_userpost.sql
pm/daily_userpost/etl/daily_userpost.sql
+273
-1
data_by_day_new.sql
pm/daily_userpost/report/data_by_day_new.sql
+1
-1
data_by_day_old.sql
pm/daily_userpost/report/data_by_day_old.sql
+15
-0
detail_data_new.sql
pm/daily_userpost/report/detail_data_new.sql
+1
-1
detail_data_old.sql
pm/daily_userpost/report/detail_data_old.sql
+62
-0
key_data_new.sql
pm/daily_userpost/report/key_data_new.sql
+1
-1
key_data_old.sql
pm/daily_userpost/report/key_data_old.sql
+28
-0
No files found.
pm/daily_recommend_strategy/etl/daily_recommend_strategy.sql
View file @
4e8450c7
...
...
@@ -674,7 +674,7 @@ FROM
partition_date
,
device_id
,
device_os_type
,
case
WHEN
active_type
=
'4'
THEN
'老活跃设备'
WHEN
active_type
in
(
'1'
,
'2'
)
then
'新增设备'
END
as
active_type
,
'灰度'
AS
grey_type
,
CASE
WHEN
substr
(
md5
(
device_id
),
-
1
,
1
)
IN
(
'0'
,
'1'
,
'2'
,
'3'
,
'8'
,
'a'
,
'b'
,
'f'
)
THEN
'非灰'
ELSE
'灰度'
END
AS
grey_type
FROM
online
.
ml_device_day_active_status
where
partition_date
=
regexp_replace
(
DATE_SUB
(
current_date
,
1
)
,
'-'
,
''
)
AND
active_type
in
(
'1'
,
'2'
,
'4'
)
...
...
pm/daily_userpost/en-cn.properties
View file @
4e8450c7
daily_userpost
=
新手精选帖日报
data_by_day
=
每日数据汇总
key_data
=
当日数据关键指标
detail_data
=
当日数据明细
\ No newline at end of file
daily_userpost
=
新手精选及更美优选帖日报
data_by_day_new
=
新手精选每日数据汇总
key_data_new
=
新手精选当日数据关键指标
detail_data_new
=
新手精选当日数据明细
data_by_day_old
=
更美优选每日数据汇总
key_data_old
=
更美优选当日数据关键指标
detail_data_old
=
更美优选当日数据明细
\ No newline at end of file
pm/daily_userpost/etl/create_userpost_old_v3.sql
0 → 100644
View file @
4e8450c7
--***************************************************************
--*脚本名称:
--*功能: 针对老用户的更美优选标签
--*业务名称: pm
--*输入数据:
--*作者: weiyimin@igengmei.com
--*更新时间:
--***************************************************************
--设置全局变量&UDF
SET
mapreduce
.
job
.
queuename
=
data
;
--使用bl数据库
USE
pm
;
--创建BL层内部表
CREATE
TABLE
IF
NOT
EXISTS
pm
.
tl_pm_userpost_old_d_v3
(
post_id
string
comment
'{"chs_name":"帖子id","description":"","etl":"","value":"","remark":""}'
,
title
string
comment
'{"chs_name":"帖子标题","description":"","etl":"","value":"","remark":""}'
,
audit_date
string
comment
'{"chs_name":"最新审核时间","description":"","etl":"","value":"","remark":""}'
,
tag_list
string
comment
'{"chs_name":"关联标签","description":"","etl":"","value":"","remark":""}'
,
exp_pv_1
bigint
comment
'{"chs_name":"前1日曝光","description":"","etl":"","value":"","remark":""}'
,
click_pv_1
bigint
comment
'{"chs_name":"前1日点击","description":"","etl":"","value":"","remark":""}'
,
page_pv_1
bigint
comment
'{"chs_name":"前1日浏览pv","description":"","etl":"","value":"","remark":""}'
,
page_pv_20s_1
bigint
comment
'{"chs_name":"前1日浏览20s以上pv","description":"","etl":"","value":"","remark":""}'
,
reply_num_1
bigint
comment
'{"chs_name":"前1日真实评论","description":"","etl":"","value":"","remark":""}'
,
vote_num_1
bigint
comment
'{"chs_name":"前1日真实点赞","description":"","etl":"","value":"","remark":""}'
,
favor_num_1
bigint
comment
'{"chs_name":"前1日收藏","description":"","etl":"","value":"","remark":""}'
,
share_num_1
bigint
comment
'{"chs_name":"前1日转发","description":"","etl":"","value":"","remark":""}'
,
avg_page_stay_1
double
comment
'{"chs_name":"前1日平均阅读时长(s)","description":"","etl":"","value":"","remark":""}'
,
exp_pv_3
bigint
comment
'{"chs_name":"前3日曝光","description":"","etl":"","value":"","remark":""}'
,
click_pv_3
bigint
comment
'{"chs_name":"前3日点击","description":"","etl":"","value":"","remark":""}'
,
page_pv_3
bigint
comment
'{"chs_name":"前3日浏览pv","description":"","etl":"","value":"","remark":""}'
,
page_pv_20s_3
bigint
comment
'{"chs_name":"前3日浏览20s以上pv","description":"","etl":"","value":"","remark":""}'
,
reply_num_3
bigint
comment
'{"chs_name":"前3日真实评论","description":"","etl":"","value":"","remark":""}'
,
vote_num_3
bigint
comment
'{"chs_name":"前3日真实点赞","description":"","etl":"","value":"","remark":""}'
,
favor_num_3
bigint
comment
'{"chs_name":"前3日收藏","description":"","etl":"","value":"","remark":""}'
,
share_num_3
bigint
comment
'{"chs_name":"前3日转发","description":"","etl":"","value":"","remark":""}'
,
avg_page_stay_3
double
comment
'{"chs_name":"前3日平均阅读时长(s)","description":"","etl":"","value":"","remark":""}'
,
exp_pv_10
bigint
comment
'{"chs_name":"前10日曝光","description":"","etl":"","value":"","remark":""}'
,
click_pv_10
bigint
comment
'{"chs_name":"前10日点击","description":"","etl":"","value":"","remark":""}'
,
page_pv_10
bigint
comment
'{"chs_name":"前10日浏览pv","description":"","etl":"","value":"","remark":""}'
,
page_pv_20s_10
bigint
comment
'{"chs_name":"前10日浏览20s以上pv","description":"","etl":"","value":"","remark":""}'
,
reply_num_10
bigint
comment
'{"chs_name":"前10日真实评论","description":"","etl":"","value":"","remark":""}'
,
vote_num_10
bigint
comment
'{"chs_name":"前10日真实点赞","description":"","etl":"","value":"","remark":""}'
,
favor_num_10
bigint
comment
'{"chs_name":"前10日收藏","description":"","etl":"","value":"","remark":""}'
,
share_num_10
bigint
comment
'{"chs_name":"前10日转发","description":"","etl":"","value":"","remark":""}'
,
avg_page_stay_10
double
comment
'{"chs_name":"前10日平均阅读时长(s)","description":"","etl":"","value":"","remark":""}'
,
exp_pv
bigint
comment
'{"chs_name":"历史曝光","description":"","etl":"","value":"","remark":""}'
,
click_pv
bigint
comment
'{"chs_name":"历史点击","description":"","etl":"","value":"","remark":""}'
,
page_pv
bigint
comment
'{"chs_name":"历史浏览pv","description":"","etl":"","value":"","remark":""}'
,
page_pv_20s
bigint
comment
'{"chs_name":"历史浏览20s以上pv","description":"","etl":"","value":"","remark":""}'
,
reply_num
bigint
comment
'{"chs_name":"历史真实评论","description":"","etl":"","value":"","remark":""}'
,
vote_num
bigint
comment
'{"chs_name":"历史真实点赞","description":"","etl":"","value":"","remark":""}'
,
favor_num
bigint
comment
'{"chs_name":"历史收藏","description":"","etl":"","value":"","remark":""}'
,
share_num
bigint
comment
'{"chs_name":"历史转发","description":"","etl":"","value":"","remark":""}'
,
avg_page_stay
double
comment
'{"chs_name":"历史平均阅读时长(s)","description":"","etl":"","value":"","remark":""}'
)
comment
'更美优选标签日报'
PARTITIONED
BY
(
PARTITION_DAY
STRING
comment
'分区日期'
)
ROW
FORMAT
DELIMITED
FIELDS
TERMINATED
BY
'
\t
'
COLLECTION
ITEMS
TERMINATED
BY
'
\0
02'
MAP
KEYS
TERMINATED
BY
'
\0
03'
LINES
TERMINATED
BY
'
\n
'
STORED
AS
TEXTFILE
;
\ No newline at end of file
pm/daily_userpost/etl/create_userpost_v2.sql
View file @
4e8450c7
--***************************************************************
--*脚本名称:
--*功能:
线索日报
--*功能:
新手精选标签
--*业务名称: pm
--*输入数据:
--*作者: weiyimin@igengmei.com
...
...
pm/daily_userpost/etl/daily_userpost.sql
View file @
4e8450c7
...
...
@@ -163,7 +163,246 @@ join
and
page_name
in
(
'post_detail'
,
'user_post_detail'
,
'doctor_post_detail'
)
group
by
partition_date
,
cl_id
,
params
[
'business_id'
]
)
f
on
a
.
partition_date
=
f
.
partition_date
and
nvl
(
a
.
card_id
,
e
.
business_id
)
=
f
.
business_id
and
nvl
(
a
.
cl_id
,
e
.
cl_id
)
=
f
.
cl_id
on
nvl
(
a
.
partition_date
,
e
.
partition_date
)
=
f
.
partition_date
and
nvl
(
a
.
card_id
,
e
.
business_id
)
=
f
.
business_id
and
nvl
(
a
.
cl_id
,
e
.
cl_id
)
=
f
.
cl_id
left
join
(
select
distinct
device_id
from
ML
.
ML_D_CT_DV_DEVICECLEAN_DIMEN_D
where
PARTITION_DAY
=
regexp_replace
(
DATE_SUB
(
current_date
,
1
)
,
'-'
,
''
)
AND
is_abnormal_device
=
'true'
)
c
on
nvl
(
nvl
(
a
.
cl_id
,
e
.
cl_id
),
f
.
cl_id
)
=
c
.
device_id
where
c
.
device_id
is
null
group
by
nvl
(
nvl
(
a
.
card_id
,
e
.
business_id
),
f
.
business_id
),
nvl
(
nvl
(
a
.
partition_date
,
e
.
partition_date
),
f
.
partition_date
)
)
t1
full
join
(
SELECT
a
.
tractate_id
,
a
.
create_date
,
sum
(
case
when
type
=
'reply'
then
num
end
)
as
reply_num
,
sum
(
case
when
type
=
'vote'
then
num
end
)
as
vote_num
,
sum
(
case
when
type
=
'favor'
then
num
end
)
as
favor_num
,
sum
(
case
when
type
=
'share'
then
num
end
)
as
share_num
from
(
--真实评论数
SELECT
tractate_id
,
create_date
,
a
.
user_id
,
'reply'
as
type
,
sum
(
reply_num
)
as
num
from
(
--评论数
SELECT
tractate_id
,
user_id
,
regexp_replace
(
substr
(
create_time
,
1
,
10
),
'-'
,
''
)
as
create_date
,
count
(
distinct
create_time
)
as
reply_num
FROM
online
.
tl_hdfs_api_tractate_reply_view
WHERE
partition_date
=
regexp_replace
(
DATE_SUB
(
current_date
,
1
)
,
'-'
,
''
)
-- and regexp_replace(substr(create_time,1,10),'-','') >= '20200101'
-- and regexp_replace(substr(create_time,1,10),'-','') < '${end_date}'
GROUP
by
tractate_id
,
user_id
,
regexp_replace
(
substr
(
create_time
,
1
,
10
),
'-'
,
''
)
)
a
group
by
tractate_id
,
create_date
,
a
.
user_id
union
all
--真实点赞数
SELECT
tractate_id
,
create_date
,
a
.
user_id
,
'vote'
as
type
,
sum
(
vote_num
)
as
num
FROM
(
SELECT
tractate_id
,
user_id
,
regexp_replace
(
substr
(
create_time
,
1
,
10
),
'-'
,
''
)
as
create_date
,
count
(
distinct
create_time
)
as
vote_num
FROM
online
.
tl_hdfs_api_tractate_vote_view
WHERE
partition_date
=
regexp_replace
(
date_sub
(
current_date
(),
1
),
'-'
,
''
)
-- and regexp_replace(substr(create_time,1,10),'-','') >= '20200101'
-- and regexp_replace(substr(create_time,1,10),'-','') < '${end_date}'
group
by
tractate_id
,
user_id
,
regexp_replace
(
substr
(
create_time
,
1
,
10
),
'-'
,
''
)
)
a
GROUP
BY
tractate_id
,
create_date
,
a
.
user_id
union
all
--真实收藏数
SELECT
tractate_id
,
regexp_replace
(
substr
(
create_time
,
1
,
10
),
'-'
,
''
)
as
create_date
,
user_id
,
'favor'
as
type
,
count
(
distinct
create_time
)
as
num
FROM
online
.
tl_hdfs_api_tractate_favor_view
WHERE
partition_date
=
regexp_replace
(
date_sub
(
current_date
(),
1
),
'-'
,
''
)
-- and regexp_replace(substr(create_time,1,10),'-','') >= '${start_date}'
-- and regexp_replace(substr(create_time,1,10),'-','') < '${end_date}'
group
by
user_id
,
tractate_id
,
regexp_replace
(
substr
(
create_time
,
1
,
10
),
'-'
,
''
)
union
all
--点击分享数
SELECT
params
[
'business_id'
]
as
tractate_id
,
partition_date
as
create_date
,
user_id
,
'share'
as
type
,
count
(
distinct
time_str
)
as
num
FROM
online
.
bl_hdfs_maidian_updates
WHERE
partition_date
>=
'20160101'
and
partition_date
<=
regexp_replace
(
DATE_SUB
(
current_date
,
1
)
,
'-'
,
''
)
and
action
=
'page_click_share'
and
page_name
in
(
'post_detail'
,
'user_post_detail'
,
'doctor_post_detail'
)
group
by
params
[
'business_id'
],
partition_date
,
user_id
)
a
left
join
(
select
distinct
user_id
from
ml
.
ML_D_CT_UI_USERCLEAN_DIMEN_D
where
PARTITION_DAY
=
regexp_replace
(
DATE_SUB
(
current_date
,
1
)
,
'-'
,
''
)
and
is_abnormal_user
=
'true'
)
b
on
a
.
user_id
=
b
.
user_id
where
b
.
user_id
is
null
group
by
a
.
tractate_id
,
a
.
create_date
)
t2
on
t1
.
card_id
=
t2
.
tractate_id
and
t1
.
partition_date
=
t2
.
create_date
)
t2
on
t1
.
id
=
t2
.
card_id
where
t2
.
partition_date
>=
t1
.
audit_date
group
by
t1
.
id
,
title
,
audit_date
,
tag_list
;
INSERT
OVERWRITE
TABLE
pm
.
tl_pm_userpost_old_d_v3
PARTITION
(
PARTITION_DAY
=
${
partition_day
}
)
SELECT
t1
.
id
as
post_id
,
title
,
audit_date
,
tag_list
,
nvl
(
sum
(
case
when
t2
.
partition_date
>=
DATE_SUB
(
current_date
,
1
)
then
exp_pv
end
),
0
)
as
exp_pv_1
,
nvl
(
sum
(
case
when
t2
.
partition_date
>=
DATE_SUB
(
current_date
,
1
)
then
click_pv
end
),
0
)
as
click_pv_1
,
nvl
(
sum
(
case
when
t2
.
partition_date
>=
DATE_SUB
(
current_date
,
1
)
then
page_pv
end
),
0
)
as
page_pv_1
,
nvl
(
sum
(
case
when
t2
.
partition_date
>=
DATE_SUB
(
current_date
,
1
)
then
page_pv_20s
end
),
0
)
as
page_pv_20s_1
,
nvl
(
sum
(
case
when
t2
.
partition_date
>=
DATE_SUB
(
current_date
,
1
)
then
reply_num
end
),
0
)
as
reply_num_1
,
nvl
(
sum
(
case
when
t2
.
partition_date
>=
DATE_SUB
(
current_date
,
1
)
then
vote_num
end
),
0
)
as
vote_num_1
,
nvl
(
sum
(
case
when
t2
.
partition_date
>=
DATE_SUB
(
current_date
,
1
)
then
favor_num
end
),
0
)
as
favor_num_1
,
nvl
(
sum
(
case
when
t2
.
partition_date
>=
DATE_SUB
(
current_date
,
1
)
then
share_num
end
),
0
)
as
share_num_1
,
nvl
(
round
(
avg
(
case
when
t2
.
partition_date
>=
DATE_SUB
(
current_date
,
1
)
then
avg_page_stay
end
),
2
),
0
)
as
avg_page_stay_1
,
nvl
(
sum
(
case
when
t2
.
partition_date
>=
DATE_SUB
(
current_date
,
3
)
then
exp_pv
end
),
0
)
as
exp_pv_3
,
nvl
(
sum
(
case
when
t2
.
partition_date
>=
DATE_SUB
(
current_date
,
3
)
then
click_pv
end
),
0
)
as
click_pv_3
,
nvl
(
sum
(
case
when
t2
.
partition_date
>=
DATE_SUB
(
current_date
,
3
)
then
page_pv
end
),
0
)
as
page_pv_3
,
nvl
(
sum
(
case
when
t2
.
partition_date
>=
DATE_SUB
(
current_date
,
3
)
then
page_pv_20s
end
),
0
)
as
page_pv_20s_3
,
nvl
(
sum
(
case
when
t2
.
partition_date
>=
DATE_SUB
(
current_date
,
3
)
then
reply_num
end
),
0
)
as
reply_num_3
,
nvl
(
sum
(
case
when
t2
.
partition_date
>=
DATE_SUB
(
current_date
,
3
)
then
vote_num
end
),
0
)
as
vote_num_3
,
nvl
(
sum
(
case
when
t2
.
partition_date
>=
DATE_SUB
(
current_date
,
3
)
then
favor_num
end
),
0
)
as
favor_num_3
,
nvl
(
sum
(
case
when
t2
.
partition_date
>=
DATE_SUB
(
current_date
,
3
)
then
share_num
end
),
0
)
as
share_num_3
,
nvl
(
round
(
avg
(
case
when
t2
.
partition_date
>=
DATE_SUB
(
current_date
,
3
)
then
avg_page_stay
end
),
2
),
0
)
as
avg_page_stay_3
,
nvl
(
sum
(
case
when
t2
.
partition_date
>=
DATE_SUB
(
current_date
,
10
)
then
exp_pv
end
),
0
)
as
exp_pv_10
,
nvl
(
sum
(
case
when
t2
.
partition_date
>=
DATE_SUB
(
current_date
,
10
)
then
click_pv
end
),
0
)
as
click_pv_10
,
nvl
(
sum
(
case
when
t2
.
partition_date
>=
DATE_SUB
(
current_date
,
10
)
then
page_pv
end
),
0
)
as
page_pv_10
,
nvl
(
sum
(
case
when
t2
.
partition_date
>=
DATE_SUB
(
current_date
,
10
)
then
page_pv_20s
end
),
0
)
as
page_pv_20s_10
,
nvl
(
sum
(
case
when
t2
.
partition_date
>=
DATE_SUB
(
current_date
,
10
)
then
reply_num
end
),
0
)
as
reply_num_10
,
nvl
(
sum
(
case
when
t2
.
partition_date
>=
DATE_SUB
(
current_date
,
10
)
then
vote_num
end
),
0
)
as
vote_num_10
,
nvl
(
sum
(
case
when
t2
.
partition_date
>=
DATE_SUB
(
current_date
,
10
)
then
favor_num
end
),
0
)
as
favor_num_10
,
nvl
(
sum
(
case
when
t2
.
partition_date
>=
DATE_SUB
(
current_date
,
10
)
then
share_num
end
),
0
)
as
share_num_10
,
nvl
(
round
(
avg
(
case
when
t2
.
partition_date
>=
DATE_SUB
(
current_date
,
10
)
then
avg_page_stay
end
),
2
),
0
)
as
avg_page_stay_10
,
nvl
(
sum
(
exp_pv
),
0
)
as
exp_pv
,
nvl
(
sum
(
click_pv
),
0
)
as
click_pv
,
nvl
(
sum
(
page_pv
),
0
)
as
page_pv
,
nvl
(
sum
(
page_pv_20s
),
0
)
as
page_pv_20s
,
nvl
(
sum
(
reply_num
),
0
)
as
reply_num
,
nvl
(
sum
(
vote_num
),
0
)
as
vote_num
,
nvl
(
sum
(
favor_num
),
0
)
as
favor_num
,
nvl
(
sum
(
share_num
),
0
)
as
share_num
,
nvl
(
round
(
avg
(
avg_page_stay
),
2
),
0
)
as
avg_page_stay
FROM
(
select
a
.
id
,
title
,
a
.
audit_date
,
collect_set
(
d
.
name
)
as
tag_list
from
(
select
id
,
title
,
user_id
,
substr
(
audit_time
,
1
,
10
)
as
audit_date
from
tl
.
tl_mp_api_tractate
where
partition_day
=
regexp_replace
(
DATE_SUB
(
current_date
,
1
)
,
'-'
,
''
)
and
content_level
>=
3
and
is_online
=
'true'
)
a
join
(
select
distinct
tractate_id
from
tl
.
tl_mp_api_tractate_tag_v3
where
partition_day
=
regexp_replace
(
DATE_SUB
(
current_date
,
1
)
,
'-'
,
''
)
and
tag_v3_id
=
'3369'
)
b
on
a
.
id
=
b
.
tractate_id
join
(
select
tractate_id
,
tag_v3_id
from
tl
.
tl_mp_api_tractate_tag_v3
where
partition_day
=
regexp_replace
(
DATE_SUB
(
current_date
,
1
)
,
'-'
,
''
)
group
by
tractate_id
,
tag_v3_id
)
c
on
a
.
id
=
c
.
tractate_id
left
join
(
select
id
,
name
from
online
.
tl_hdfs_api_tag_3_0_view
where
partition_date
=
regexp_replace
(
DATE_SUB
(
current_date
,
1
)
,
'-'
,
''
)
group
by
id
,
name
)
d
on
d
.
id
=
c
.
tag_v3_id
group
by
a
.
id
,
title
,
a
.
audit_date
)
t1
join
(
--历史数据,指从审核时间至今的数据
SELECT
nvl
(
concat_ws
(
'-'
,
substr
(
t1
.
partition_date
,
1
,
4
),
substr
(
t1
.
partition_date
,
5
,
2
),
substr
(
t1
.
partition_date
,
7
,
2
))
,
concat_ws
(
'-'
,
substr
(
t2
.
create_date
,
1
,
4
),
substr
(
t2
.
create_date
,
5
,
2
),
substr
(
t2
.
create_date
,
7
,
2
)))
as
partition_date
,
nvl
(
t1
.
card_id
,
t2
.
tractate_id
)
as
card_id
,
exp_pv
,
click_pv
,
page_pv
,
page_pv_20s
,
reply_num
,
vote_num
,
favor_num
,
share_num
,
avg_page_stay
from
(
select
nvl
(
nvl
(
a
.
card_id
,
e
.
business_id
),
f
.
business_id
)
as
card_id
,
nvl
(
nvl
(
a
.
partition_date
,
e
.
partition_date
),
f
.
partition_date
)
as
partition_date
,
sum
(
exp_pv
)
as
exp_pv
,
sum
(
click_pv
)
as
click_pv
,
sum
(
page_pv
)
as
page_pv
,
sum
(
page_pv_20s
)
as
page_pv_20s
,
round
(
sum
(
page_stay
)
/
count
(
distinct
e
.
cl_id
,
e
.
partition_date
),
2
)
as
avg_page_stay
from
(
--曝光
select
partition_date
,
card_id
,
cl_id
,
count
(
distinct
app_session_id
)
as
exp_pv
from
online
.
ml_community_precise_exposure_detail
where
partition_date
>=
'20160101'
AND
partition_date
<=
regexp_replace
(
DATE_SUB
(
current_date
,
1
)
,
'-'
,
''
)
AND
action
in
(
'page_precise_exposure'
,
'home_choiceness_card_exposure'
)
--7745版本action改为page_precise_exposure
AND
is_exposure
=
'1'
----精准曝光
AND
page_name
=
'home'
AND
tab_name
=
'精选'
group
by
partition_date
,
cl_id
,
card_id
)
a
left
join
(
--点击
SELECT
partition_date
,
params
[
'card_id'
]
as
card_id
,
cl_id
,
count
(
distinct
app_session_id
,
cl_id
)
as
click_pv
from
online
.
bl_hdfs_maidian_updates
WHERE
partition_date
>=
'20160101'
AND
partition_date
<=
regexp_replace
(
DATE_SUB
(
current_date
,
1
)
,
'-'
,
''
)
AND
action
=
'on_click_card'
AND
params
[
'page_name'
]
=
'home'
AND
params
[
'tab_name'
]
=
'精选'
GROUP
BY
partition_date
,
params
[
'card_id'
],
cl_id
)
b
on
a
.
partition_date
=
b
.
partition_date
and
a
.
card_id
=
b
.
card_id
and
a
.
cl_id
=
b
.
cl_id
full
join
(
--平均阅读时长
SELECT
partition_date
,
business_id
,
cl_id
,
page_stay
from
(
SELECT
partition_date
,
cl_id
,
params
[
'business_id'
]
as
business_id
,
page_stay
,
time_str
FROM
online
.
bl_hdfs_maidian_updates
WHERE
partition_date
>=
'20160101'
and
partition_date
<=
regexp_replace
(
DATE_SUB
(
current_date
,
1
)
,
'-'
,
''
)
and
action
=
'page_view'
and
page_stay
>=
0
and
page_stay
<
1000
and
page_name
in
(
'post_detail'
,
'user_post_detail'
,
'doctor_post_detail'
)
group
by
partition_date
,
cl_id
,
params
[
'business_id'
],
page_stay
,
time_str
)
a
)
e
on
a
.
partition_date
=
e
.
partition_date
and
a
.
card_id
=
e
.
business_id
and
a
.
cl_id
=
e
.
cl_id
full
join
(
--浏览pv
SELECT
partition_date
,
cl_id
,
params
[
'business_id'
]
as
business_id
,
count
(
distinct
time_str
)
as
page_pv
,
count
(
distinct
case
when
page_stay
>=
20
then
time_str
end
)
as
page_pv_20s
FROM
online
.
bl_hdfs_maidian_updates
WHERE
partition_date
>=
'20160101'
and
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'
)
group
by
partition_date
,
cl_id
,
params
[
'business_id'
]
)
f
on
nvl
(
a
.
partition_date
,
e
.
partition_date
)
=
f
.
partition_date
and
nvl
(
a
.
card_id
,
e
.
business_id
)
=
f
.
business_id
and
nvl
(
a
.
cl_id
,
e
.
cl_id
)
=
f
.
cl_id
left
join
(
select
distinct
device_id
...
...
@@ -172,7 +411,16 @@ join
AND
is_abnormal_device
=
'true'
)
c
on
a
.
cl_id
=
c
.
device_id
left
join
(
select
partition_date
,
device_id
from
online
.
ml_device_day_active_status
where
partition_date
=
regexp_replace
(
DATE_SUB
(
current_date
,
1
)
,
'-'
,
''
)
and
active_type
in
(
'1'
,
'2'
)
)
d
on
nvl
(
nvl
(
a
.
cl_id
,
e
.
cl_id
),
f
.
cl_id
)
=
d
.
device_id
and
nvl
(
nvl
(
a
.
partition_date
,
e
.
partition_date
),
f
.
partition_date
)
=
d
.
partition_date
where
c
.
device_id
is
null
and
d
.
device_id
is
null
group
by
nvl
(
nvl
(
a
.
card_id
,
e
.
business_id
),
f
.
business_id
),
nvl
(
nvl
(
a
.
partition_date
,
e
.
partition_date
),
f
.
partition_date
)
)
t1
full
join
...
...
@@ -238,7 +486,29 @@ join
and
is_abnormal_user
=
'true'
)
b
on
a
.
user_id
=
b
.
user_id
left
join
(
select
a
.
partition_date
,
user_id
from
(
select
partition_date
,
device_id
from
online
.
ml_device_day_active_status
where
partition_date
=
regexp_replace
(
DATE_SUB
(
current_date
,
1
)
,
'-'
,
''
)
and
active_type
in
(
'1'
,
'2'
)
)
a
join
(
select
partition_date
,
cl_id
,
user_id
from
online
.
bl_hdfs_maidian_updates
where
partition_date
=
regexp_replace
(
DATE_SUB
(
current_date
,
1
)
,
'-'
,
''
)
and
user_id
is
not
null
and
user_id
<>
''
group
by
partition_date
,
cl_id
,
user_id
)
b
on
a
.
partition_date
=
b
.
partition_date
and
a
.
device_id
=
b
.
cl_id
)
c
on
a
.
create_date
=
c
.
partition_date
and
a
.
user_id
=
c
.
user_id
where
b
.
user_id
is
null
and
c
.
user_id
is
null
group
by
a
.
tractate_id
,
a
.
create_date
)
t2
on
t1
.
card_id
=
t2
.
tractate_id
and
t1
.
partition_date
=
t2
.
create_date
...
...
@@ -246,3 +516,5 @@ join
on
t1
.
id
=
t2
.
card_id
where
t2
.
partition_date
>=
t1
.
audit_date
group
by
t1
.
id
,
title
,
audit_date
,
tag_list
;
pm/daily_userpost/report/data_by_day.sql
→
pm/daily_userpost/report/data_by_day
_new
.sql
View file @
4e8450c7
SELECT
partition_day
as
`日期`
,
count
(
post_id
)
as
`帖子数量`
,
count
(
post_id
)
as
`
新手精选
帖子数量`
,
nvl
(
sum
(
exp_pv_1
),
0
)
as
`前1日曝光`
,
nvl
(
concat
(
round
(
sum
(
click_pv_1
)
/
sum
(
exp_pv_1
)
*
100
,
2
),
'%'
),
0
)
as
`前1日ctr`
,
nvl
(
concat
(
round
(
sum
(
page_pv_20s_1
)
/
sum
(
exp_pv_1
)
*
100
,
2
),
'%'
),
0
)
as
`日优秀浏览点击ctr`
...
...
pm/daily_userpost/report/data_by_day_old.sql
0 → 100644
View file @
4e8450c7
SELECT
partition_day
as
`日期`
,
count
(
post_id
)
as
`更美优选帖子数量`
,
nvl
(
sum
(
exp_pv_1
),
0
)
as
`前1日曝光`
,
nvl
(
concat
(
round
(
sum
(
click_pv_1
)
/
sum
(
exp_pv_1
)
*
100
,
2
),
'%'
),
0
)
as
`前1日ctr`
,
nvl
(
concat
(
round
(
sum
(
page_pv_20s_1
)
/
sum
(
exp_pv_1
)
*
100
,
2
),
'%'
),
0
)
as
`日优秀浏览点击ctr`
,
nvl
(
round
(
avg
(
avg_page_stay_1
),
2
),
0
)
as
`前1日平均阅读时长(s)`
,
nvl
(
sum
(
exp_pv
),
0
)
as
`历史曝光`
,
nvl
(
concat
(
round
(
sum
(
click_pv
)
/
sum
(
exp_pv
)
*
100
,
2
),
'%'
),
0
)
as
`历史ctr`
,
nvl
(
concat
(
round
(
sum
(
page_pv_20s
)
/
sum
(
exp_pv
)
*
100
,
2
),
'%'
),
0
)
as
`历史优秀浏览点击ctr`
,
nvl
(
round
(
avg
(
avg_page_stay
),
2
),
0
)
as
`历史平均阅读时长(s)`
FROM
pm
.
tl_pm_userpost_d_v2
where
partition_day
>=
'20201102'
group
by
partition_day
order
by
`日期`
\ No newline at end of file
pm/daily_userpost/report/detail_data.sql
→
pm/daily_userpost/report/detail_data
_new
.sql
View file @
4e8450c7
SELECT
post_id
as
`帖子id`
SELECT
post_id
as
`
新手精选
帖子id`
,
title
as
`帖子标题`
,
audit_date
as
`审核日期`
,
tag_list
as
`所有关联标签`
...
...
pm/daily_userpost/report/detail_data_old.sql
0 → 100644
View file @
4e8450c7
SELECT
post_id
as
`更美优选帖子id`
,
title
as
`帖子标题`
,
audit_date
as
`审核日期`
,
tag_list
as
`所有关联标签`
,
nvl
(
concat
(
round
((
nvl
(
reply_num_1
,
0
)
+
nvl
(
vote_num_1
,
0
)
+
nvl
(
favor_num_1
,
0
)
+
nvl
(
share_num_1
,
0
))
/
page_pv_1
*
100
,
2
),
'%'
),
0
)
as
`前1日互动率`
,
nvl
(
concat
(
round
(
click_pv_1
/
exp_pv_1
*
100
,
2
),
'%'
),
0
)
as
`前1日ctr`
,
nvl
(
concat
(
round
(
page_pv_20s_1
/
page_pv_1
*
100
,
2
),
'%'
),
0
)
as
`前1日浏览20s以上pv/前1日总浏览pv`
,
nvl
(
click_pv_1
,
0
)
as
`前1日点击`
,
nvl
(
exp_pv_1
,
0
)
as
`前1日曝光`
,
nvl
(
page_pv_1
,
0
)
as
`前1日浏览pv`
,
nvl
(
page_pv_20s_1
,
0
)
as
`前1日浏览20s以上pv`
,
nvl
(
reply_num_1
,
0
)
as
`前1日真实评论`
,
nvl
(
vote_num_1
,
0
)
as
`前1日真实点赞`
,
nvl
(
favor_num_1
,
0
)
as
`前1日收藏`
,
nvl
(
share_num_1
,
0
)
as
`前1日转发`
,
nvl
(
avg_page_stay_1
,
0
)
as
`前1日平均阅读时长(s)`
,
nvl
(
concat
(
round
((
nvl
(
reply_num_3
,
0
)
+
nvl
(
vote_num_3
,
0
)
+
nvl
(
favor_num_3
,
0
)
+
nvl
(
share_num_3
,
0
))
/
page_pv_3
*
100
,
2
),
'%'
),
0
)
as
`前3日互动率`
,
nvl
(
concat
(
round
(
click_pv_3
/
exp_pv_3
*
100
,
2
),
'%'
),
0
)
as
`前3日ctr`
,
nvl
(
concat
(
round
(
page_pv_20s_3
/
page_pv_3
*
100
,
2
),
'%'
),
0
)
as
`前3日浏览20s以上pv/前3日总浏览pv`
,
nvl
(
click_pv_3
,
0
)
as
`前3日点击`
,
nvl
(
exp_pv_3
,
0
)
as
`前3日曝光`
,
nvl
(
page_pv_3
,
0
)
as
`前3日浏览pv`
,
nvl
(
page_pv_20s_3
,
0
)
as
`前3日浏览20s以上pv`
,
nvl
(
reply_num_3
,
0
)
as
`前3日真实评论`
,
nvl
(
vote_num_3
,
0
)
as
`前3日真实点赞`
,
nvl
(
favor_num_3
,
0
)
as
`前3日收藏`
,
nvl
(
share_num_3
,
0
)
as
`前3日转发`
,
nvl
(
avg_page_stay_3
,
0
)
as
`前3日平均阅读时长(s)`
,
nvl
(
concat
(
round
((
nvl
(
reply_num_10
,
0
)
+
nvl
(
vote_num_10
,
0
)
+
nvl
(
favor_num_10
,
0
)
+
nvl
(
share_num_10
,
0
))
/
page_pv_10
*
100
,
2
),
'%'
),
0
)
as
`前10日互动率`
,
nvl
(
concat
(
round
(
click_pv_10
/
exp_pv_10
*
100
,
2
),
'%'
),
0
)
as
`前10日ctr`
,
nvl
(
concat
(
round
(
page_pv_20s_10
/
page_pv_10
*
100
,
2
),
'%'
),
0
)
as
`前10日浏览20s以上pv/前10日总浏览pv`
,
nvl
(
click_pv_10
,
0
)
as
`前10日点击`
,
nvl
(
exp_pv_10
,
0
)
as
`前10日曝光`
,
nvl
(
page_pv_10
,
0
)
as
`前10日浏览pv`
,
nvl
(
page_pv_20s_10
,
0
)
as
`前10日浏览20s以上pv`
,
nvl
(
reply_num_10
,
0
)
as
`前10日真实评论`
,
nvl
(
vote_num_10
,
0
)
as
`前10日真实点赞`
,
nvl
(
favor_num_10
,
0
)
as
`前10日收藏`
,
nvl
(
share_num_10
,
0
)
as
`前10日转发`
,
nvl
(
avg_page_stay_10
,
0
)
as
`前10日平均阅读时长(s)`
,
nvl
(
concat
(
round
((
nvl
(
reply_num
,
0
)
+
nvl
(
vote_num
,
0
)
+
nvl
(
favor_num
,
0
)
+
nvl
(
share_num
,
0
))
/
page_pv
*
100
,
2
),
'%'
),
0
)
as
`历史互动率`
,
nvl
(
concat
(
round
(
click_pv
/
exp_pv
*
100
,
2
),
'%'
),
0
)
as
`历史ctr`
,
nvl
(
concat
(
round
(
page_pv_20s
/
page_pv
*
100
,
2
),
'%'
),
0
)
as
`历史浏览20s以上pv/历史总浏览pv`
,
nvl
(
click_pv
,
0
)
as
`历史点击`
,
nvl
(
exp_pv
,
0
)
as
`历史曝光`
,
nvl
(
page_pv
,
0
)
as
`历史浏览pv`
,
nvl
(
page_pv_20s
,
0
)
as
`历史浏览20s以上pv`
,
nvl
(
reply_num
,
0
)
as
`历史真实评论`
,
nvl
(
vote_num
,
0
)
as
`历史真实点赞`
,
nvl
(
favor_num
,
0
)
as
`历史收藏`
,
nvl
(
share_num
,
0
)
as
`历史转发`
,
nvl
(
avg_page_stay
,
0
)
as
`历史平均阅读时长(s)`
FROM
pm
.
tl_pm_userpost_d_v2
where
partition_day
=
regexp_replace
(
DATE_SUB
(
current_date
,
1
)
,
'-'
,
''
)
order
by
`前10日曝光`
desc
pm/daily_userpost/report/key_data.sql
→
pm/daily_userpost/report/key_data
_new
.sql
View file @
4e8450c7
SELECT
post_id
as
`帖子id`
SELECT
post_id
as
`
新手精选
帖子id`
,
title
as
`帖子标题`
,
audit_date
as
`审核日期`
,
tag_list
as
`所有关联标签`
...
...
pm/daily_userpost/report/key_data_old.sql
0 → 100644
View file @
4e8450c7
SELECT
post_id
as
`更美优选帖子id`
,
title
as
`帖子标题`
,
audit_date
as
`审核日期`
,
tag_list
as
`所有关联标签`
,
nvl
(
concat
(
round
(
click_pv_1
/
exp_pv_1
*
100
,
2
),
'%'
),
0
)
as
`前1日ctr`
,
nvl
(
concat
(
round
(
page_pv_20s_1
/
page_pv_1
*
100
,
2
),
'%'
),
0
)
as
`前1日浏览20s以上pv/前1日总浏览pv`
,
nvl
(
exp_pv_1
,
0
)
as
`前1日曝光`
,
nvl
(
avg_page_stay_1
,
0
)
as
`前1日平均阅读时长(s)`
,
nvl
(
concat
(
round
(
click_pv_3
/
exp_pv_3
*
100
,
2
),
'%'
),
0
)
as
`前3日ctr`
,
nvl
(
concat
(
round
(
page_pv_20s_3
/
page_pv_3
*
100
,
2
),
'%'
),
0
)
as
`前3日浏览20s以上pv/前3日总浏览pv`
,
nvl
(
exp_pv_3
,
0
)
as
`前3日曝光`
,
nvl
(
avg_page_stay_3
,
0
)
as
`前3日平均阅读时长(s)`
,
nvl
(
concat
(
round
(
click_pv_10
/
exp_pv_10
*
100
,
2
),
'%'
),
0
)
as
`前10日ctr`
,
nvl
(
concat
(
round
(
page_pv_20s_10
/
page_pv_10
*
100
,
2
),
'%'
),
0
)
as
`前10日浏览20s以上pv/前10日总浏览pv`
,
nvl
(
exp_pv_10
,
0
)
as
`前10日曝光`
,
nvl
(
avg_page_stay_10
,
0
)
as
`前10日平均阅读时长(s)`
,
nvl
(
concat
(
round
(
click_pv
/
exp_pv
*
100
,
2
),
'%'
),
0
)
as
`历史ctr`
,
nvl
(
concat
(
round
(
page_pv_20s
/
page_pv
*
100
,
2
),
'%'
),
0
)
as
`历史浏览20s以上pv/历史总浏览pv`
,
nvl
(
exp_pv
,
0
)
as
`历史曝光`
,
nvl
(
page_pv
,
0
)
as
`历史浏览pv`
,
nvl
(
avg_page_stay
,
0
)
as
`历史平均阅读时长(s)`
FROM
pm
.
tl_pm_userpost_d_v2
where
partition_day
=
regexp_replace
(
DATE_SUB
(
current_date
,
1
)
,
'-'
,
''
)
order
by
`前10日曝光`
desc
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