Commit c3caf28b authored by 王志伟's avatar 王志伟

统计多天重复日记数量

parent 80bba4a8
......@@ -304,13 +304,14 @@ object Repeated_content_recommendation_moreday {
// val stat_date = GmeiConfig.getMinusNDate(1)
val stat_date = "2019-01-16"
// val stat_date = "2019-01-16"
// val partition_date = stat_date.replace("-","")
val now= new Date()
val dateFormat = new SimpleDateFormat("yyyy-MM-dd")
val date = dateFormat.format(now.getTime - 86400000L * 15)
val today=dateFormat.format(now)
val exp_diary = sc.sql(
......@@ -318,8 +319,7 @@ object Repeated_content_recommendation_moreday {
|select stat_date,device_id,concat_ws(',',collect_set(distinct cid_id)) as expoure_diary
|from data_feed_exposure_precise
|where cid_type = 'diary'
|and stat_date >='2018-12-31'
|and stat_date <'2019-01-16'
|and stat_date >='${date}'
|group by device_id,stat_date
""".stripMargin
).rdd.map(row=>(row(0).toString,row(1).toString,row(2).toString)).map(row=>(row._2,row._3)).groupByKey()
......@@ -338,7 +338,7 @@ object Repeated_content_recommendation_moreday {
val fenzi = count_imp.map(x => x._2).reduce((x,y) => x+y)
val repeated_rate= fenmu / fenzi.toDouble
val result=List((stat_date,repeated_rate))
val result=List((today,repeated_rate))
val df_result = sc.createDataFrame(result)
GmeiConfig.writeToJDBCTable(df_result, table = "Repeated_content_recommendation_moreday", SaveMode.Append)
......
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