Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
ffm-baseline
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ML
ffm-baseline
Commits
734506ff
Commit
734506ff
authored
Dec 10, 2018
by
王志伟
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新统计指标
parent
271a6100
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
95 additions
and
56 deletions
+95
-56
testt.scala
eda/feededa/src/main/scala/com/gmei/testt.scala
+95
-56
No files found.
eda/feededa/src/main/scala/com/gmei/testt.scala
View file @
734506ff
...
...
@@ -46,63 +46,102 @@ object testt {
ti
.
tidbMapTable
(
dbName
=
"jerry_prod"
,
tableName
=
"blacklist"
)
ti
.
tidbMapTable
(
dbName
=
"jerry_prod"
,
tableName
=
"data_feed_exposure"
)
val
stat_date
=
GmeiConfig
.
getMinusNDate
(
1
)
val
partition_date
=
stat_date
.
replace
(
"-"
,
""
)
//机构id
// val agency_id = sc.sql(
// s"""
// |SELECT DISTINCT(cl_id) as device_id
// |FROM online.ml_hospital_spam_pv_day
// |WHERE partition_date >= '20180402'
// |AND partition_date <= '20181203'
// |AND pv_ratio >= 0.95
// |UNION ALL
// |SELECT DISTINCT(cl_id) as device_id
// |FROM online.ml_hospital_spam_pv_month
// |WHERE partition_date >= '20171101'
// |AND partition_date <= '20181203'
// |AND pv_ratio >= 0.95
// """.stripMargin
// )
//// agency_id.show()
// agency_id.createOrReplaceTempView("agency_id")
val
a
=
Array
(
"answer_detail"
,
"article_detail"
,
"diary_detail"
,
"home_page"
,
"question_detail"
,
"search_content"
,
"search_diary"
)
for
(
i
<-
0
until
a
.
length
){
val
diary_pv
=
sc
.
sql
(
s
"""
|select partition_date,count(cl_id)
|from online.ml_community_exposure_detail
|where business_type ='diary'
|and partition_date >='20181120'
|and event='${a(i)}'
|GROUP BY partition_date
|order by partition_date
"""
.
stripMargin
)
println
(
"该来源的数据为:"
+
a
(
i
))
diary_pv
.
show
()
}
// val diary_pv = sc.sql(
// s"""
// |select partition_date,count(cl_id)
// |from online.tl_hdfs_maidian_view
// |where action ='on_click_diary_card'
// |and params["page_name"]="home"
// |and params["tab_name"]="精选"
// |and partition_date >='20181120'
// |GROUP BY partition_date
// |order by partition_date
// """.stripMargin
// )
// diary_pv.show()
// GmeiConfig.writeToJDBCTable(view_count, "avg", SaveMode.Overwrite)
val
agency_id
=
sc
.
sql
(
s
"""
|SELECT DISTINCT(cl_id) as device_id
|FROM online.ml_hospital_spam_pv_day
|WHERE partition_date >= '20180402'
|AND partition_date <= '20181203'
|AND pv_ratio >= 0.95
|UNION ALL
|SELECT DISTINCT(cl_id) as device_id
|FROM online.ml_hospital_spam_pv_month
|WHERE partition_date >= '20171101'
|AND partition_date <= '20181203'
|AND pv_ratio >= 0.95
"""
.
stripMargin
)
// agency_id.show()
agency_id
.
createOrReplaceTempView
(
"agency_id"
)
//日记本转化美购
//1.日记本到美购转化数
val
diary_meigou_count
=
sc
.
sql
(
s
"""
|select '${stat_date}' as stat_date, count(page_name) as diary_meigou_count
|from online.bl_hdfs_page_view_updates ou left join agency_id
|on ou.cl_id = agency_id.device_id
|where ou.partition_date = '${partition_date}'
|and ou.page_name='welfare_detail'
|and ou.referrer='diary_detail'
|and agency_id.device_id is not null
|and ou.cl_id not in (select device_id from blacklist)
"""
.
stripMargin
)
//2.日记本点击数
val
diary_clk
=
sc
.
sql
(
s
"""
|select '${stat_date}' as stat_date,count(cl_id) as diary_clk
|from online.tl_hdfs_maidian_view ov left join agency_id
|on ov.cl_id = agency_id.device_id
|where ov.action = 'on_click_diary_card'
|and ov.cl_id != "NULL"
|and ov.partition_date='${partition_date}'
|and agency_id.device_id is not null
|and ov.cl_id not in (select device_id from blacklist)
"""
.
stripMargin
)
//3.日记本曝光数
val
diary_expoure
=
sc
.
sql
(
s
"""
|select '${stat_date}' as stat_date,count(cl_id) as diary_expoure
|from online.ml_community_exposure_detail od left join agency_id
|on od.cl_id = agency_id.device_id
|where od.business_type = "diary"
|and od.cl_id != "NULL"
|and od.partition_date='${partition_date}'
|and agency_id.device_id is not null
|and od.cl_id not in (select device_id from blacklist)
"""
.
stripMargin
)
//4.搜索次数统计
val
search_count
=
sc
.
sql
(
s
"""
|select '${stat_date}' as stat_date,count(params['query']) as search_num
|from online.tl_hdfs_maidian_view ov left join agency_id
|on ov.cl_id = agency_id.device_id
|where (ov.action = 'do_search' or ov.action = 'search_result_click_search')
|and ov.partition_date ='${partition_date}'
|and agency_id.device_id is not null
|and ov.cl_id not in (select device_id from blacklist)
"""
.
stripMargin
)
//5.登录人数
val
log_num
=
sc
.
sql
(
s
"""
|select '${stat_date}' as stat_date,count(distinct(device_id)) as log_num
|from data_feed_exposure oe left join agency_id
|on oe.device_id = agency_id.device_id
|and oe.stat_date ='${stat_date}'
|and agency_id.device_id is not null
|and oe.device_id not in (select device_id from blacklist)
"""
.
stripMargin
)
val
result
=
diary_meigou_count
.
join
(
diary_clk
,
"stat_date"
)
.
join
(
diary_expoure
,
"stat_date"
)
.
join
(
search_count
,
"stat_date"
)
.
join
(
log_num
,
"stat_date"
)
GmeiConfig
.
writeToJDBCTable
(
result
,
"diary_meigou_crv"
,
SaveMode
.
Overwrite
)
}
...
...
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