Commit 8ab1cc5c authored by 王志伟's avatar 王志伟

拆分新老用户重复曝光指标

parent 1f7ce98c
...@@ -313,29 +313,29 @@ object Repeated_content_recommendation { ...@@ -313,29 +313,29 @@ object Repeated_content_recommendation {
GmeiConfig.writeToJDBCTable(df1, table = "Repeated_evaluation_indicator_new", SaveMode.Append) GmeiConfig.writeToJDBCTable(df1, table = "Repeated_evaluation_indicator_new", SaveMode.Append)
val exp_diary_old = sc.sql( // val exp_diary_old = sc.sql(
s""" // s"""
|select concat_ws('|',de.device_id,de.cid_id) // |select concat_ws('|',de.device_id,de.cid_id)
|from data_feed_exposure de inner join device_id_old // |from data_feed_exposure de inner join device_id_old
|where de.cid_type = 'diary' // |where de.cid_type = 'diary'
|and de.stat_date ='${stat_date}' // |and de.stat_date ='${stat_date}'
""".stripMargin // """.stripMargin
) // )
val get_result_old =exp_diary_old.rdd.map((_, 1)).reduceByKey(_ + _) // val get_result_old =exp_diary_old.rdd.map((_, 1)).reduceByKey(_ + _)
.sortBy(_._2,false) // .sortBy(_._2,false)
//
val more_than2_old=get_result_old.filter(_._2 >=2).map(_._2).reduce((x,y)=>x+y) // val more_than2_old=get_result_old.filter(_._2 >=2).map(_._2).reduce((x,y)=>x+y)
println(more_than2_old) // println(more_than2_old)
val all_old =get_result_old.map(_._2).reduce((x,y)=>x+y) // val all_old =get_result_old.map(_._2).reduce((x,y)=>x+y)
println(all_old) // println(all_old)
val repeated_rate_old= more_than2_old / all_old.toDouble // val repeated_rate_old= more_than2_old / all_old.toDouble
println(repeated_rate_old) // println(repeated_rate_old)
//
//
val result2=List((stat_date,more_than2_old,all_old)) // val result2=List((stat_date,more_than2_old,all_old))
val df2 = sc.createDataFrame(result2).toDF("stat_date","old_rep_count","old_imp_all") // val df2 = sc.createDataFrame(result2).toDF("stat_date","old_rep_count","old_imp_all")
//
GmeiConfig.writeToJDBCTable(df2, table = "Repeated_evaluation_indicator_old", SaveMode.Append) // GmeiConfig.writeToJDBCTable(df2, table = "Repeated_evaluation_indicator_old", SaveMode.Append)
// val temp=get_result.collect() // val temp=get_result.collect()
......
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