Commit 66784e77 authored by 张彦钊's avatar 张彦钊

Merge branch 'master' of git.wanmeizhensuo.com:ML/ffm-baseline

add print
parents 2e145983 ccac05f8
...@@ -14,7 +14,8 @@ object testt { ...@@ -14,7 +14,8 @@ object testt {
Logger.getLogger("org.apache.spark").setLevel(Level.WARN) Logger.getLogger("org.apache.spark").setLevel(Level.WARN)
Logger.getLogger("org.apache.eclipse.jetty.server").setLevel(Level.OFF) Logger.getLogger("org.apache.eclipse.jetty.server").setLevel(Level.OFF)
case class Params(env: String = "dev" case class Params(env: String = "dev",
date: String = "2018-08-01"
) extends AbstractParams[Params] with Serializable ) extends AbstractParams[Params] with Serializable
val defaultParams = Params() val defaultParams = Params()
...@@ -24,6 +25,9 @@ object testt { ...@@ -24,6 +25,9 @@ object testt {
opt[String]("env") opt[String]("env")
.text(s"the databases environment you used") .text(s"the databases environment you used")
.action((x, c) => c.copy(env = x)) .action((x, c) => c.copy(env = x))
opt[String] ("date")
.text(s"the date you used")
.action((x,c) => c.copy(date = x))
note( note(
""" """
|For example, the following command runs this app on a tidb dataset: |For example, the following command runs this app on a tidb dataset:
...@@ -46,63 +50,103 @@ object testt { ...@@ -46,63 +50,103 @@ object testt {
ti.tidbMapTable(dbName = "jerry_prod", tableName = "blacklist") ti.tidbMapTable(dbName = "jerry_prod", tableName = "blacklist")
ti.tidbMapTable(dbName = "jerry_prod", tableName = "data_feed_exposure") ti.tidbMapTable(dbName = "jerry_prod", tableName = "data_feed_exposure")
// val stat_date = GmeiConfig.getMinusNDate(1)
val stat_date=param.date
val partition_date = stat_date.replace("-","")
//机构id //机构id
// val agency_id = sc.sql( val agency_id = sc.sql(
// s""" s"""
// |SELECT DISTINCT(cl_id) as device_id |SELECT DISTINCT(cl_id) as device_id
// |FROM online.ml_hospital_spam_pv_day |FROM online.ml_hospital_spam_pv_day
// |WHERE partition_date >= '20180402' |WHERE partition_date >= '20180402'
// |AND partition_date <= '20181203' |AND partition_date <= '20181203'
// |AND pv_ratio >= 0.95 |AND pv_ratio >= 0.95
// |UNION ALL |UNION ALL
// |SELECT DISTINCT(cl_id) as device_id |SELECT DISTINCT(cl_id) as device_id
// |FROM online.ml_hospital_spam_pv_month |FROM online.ml_hospital_spam_pv_month
// |WHERE partition_date >= '20171101' |WHERE partition_date >= '20171101'
// |AND partition_date <= '20181203' |AND partition_date <= '20181203'
// |AND pv_ratio >= 0.95 |AND pv_ratio >= 0.95
// """.stripMargin """.stripMargin
// ) )
//// agency_id.show() // agency_id.show()
// agency_id.createOrReplaceTempView("agency_id") 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( //1.日记本到美购转化数
s""" val diary_meigou_count = sc.sql(
|select partition_date,count(cl_id) s"""
|from online.ml_community_exposure_detail |select '${stat_date}' as stat_date, count(page_name) as diary_meigou_count
|where business_type ='diary' |from online.bl_hdfs_page_view_updates ou left join agency_id
|and partition_date >='20181120' |on ou.cl_id = agency_id.device_id
|and event='${a(i)}' |where ou.partition_date = '${partition_date}'
|GROUP BY partition_date |and ou.page_name='welfare_detail'
|order by partition_date |and ou.referrer='diary_detail'
""".stripMargin |and agency_id.device_id is not null
) |and ou.cl_id not in (select device_id from blacklist)
println("该来源的数据为:"+ a(i)) """.stripMargin
diary_pv.show() )
}
//2.日记本点击数
val diary_clk = sc.sql(
// val diary_pv = sc.sql( s"""
// s""" |select '${stat_date}' as stat_date,count(cl_id) as diary_clk
// |select partition_date,count(cl_id) |from online.tl_hdfs_maidian_view ov left join agency_id
// |from online.tl_hdfs_maidian_view |on ov.cl_id = agency_id.device_id
// |where action ='on_click_diary_card' |where ov.action = 'on_click_diary_card'
// |and params["page_name"]="home" |and ov.cl_id != "NULL"
// |and params["tab_name"]="精选" |and ov.partition_date='${partition_date}'
// |and partition_date >='20181120' |and agency_id.device_id is not null
// |GROUP BY partition_date |and ov.cl_id not in (select device_id from blacklist)
// |order by partition_date """.stripMargin
// """.stripMargin )
// )
// diary_pv.show() //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
// GmeiConfig.writeToJDBCTable(view_count, "avg", SaveMode.Overwrite) |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)
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment