Skip to content

Commit

Permalink
Merge pull request Sunbird-Obsrv#158 from shikshalokam/release-5.0.0
Browse files Browse the repository at this point in the history
SB-30236 - Time range filter logic to OnDemandDruidExhaust Job
  • Loading branch information
sowmya-dixit authored Jul 26, 2022
2 parents 2fa5000 + 5082fa5 commit 2a4da07
Show file tree
Hide file tree
Showing 3 changed files with 467 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,13 @@ object OnDemandDruidExhaustJob extends BaseReportsJob with Serializable with IJo
JobLogger.log(reportConfig.id + "Total Records :" + dataCount.value, None, Level.INFO)
}
else {
JobLogger.log("No data found from druid", None, Level.INFO)
JobLogger.log("No data present", None, Level.INFO)
}
}
if (fileSavedToBlob.length > 0) {
OnDemandDruidResponse(fileSavedToBlob, "SUCCESS", "", System.currentTimeMillis())
} else {
OnDemandDruidResponse(List(), "FAILED", "No data found from druid", System.currentTimeMillis())
OnDemandDruidResponse(List(), "FAILED", "No data present", System.currentTimeMillis())
}
}

Expand Down Expand Up @@ -174,8 +174,23 @@ object OnDemandDruidExhaustJob extends BaseReportsJob with Serializable with IJo
// TO:DO
// Fetch report config from dataset_metadata table
val datasetConf = getDataSetDetails(requestType)
val reportConf = if(datasetConf.druid_query.nonEmpty) JSONUtils.deserialize[Map[String,AnyRef]](datasetConf.druid_query.get) else JSONUtils.deserialize[Map[String,AnyRef]](AppConf.getConfig("druid_query." + requestType))
var reportConf = if(datasetConf.druid_query.nonEmpty) JSONUtils.deserialize[Map[String,AnyRef]](datasetConf.druid_query.get) else JSONUtils.deserialize[Map[String,AnyRef]](AppConf.getConfig("druid_query." + requestType))
val sortDfColNames = reportConf.get("sort").asInstanceOf[Option[List[String]]]
// Date Range with dynamic Start Date and End Date
if (requestParamsBody.contains("start_date")){
val intervalUpd = reportConf.getOrElse("dateRange",None).asInstanceOf[Map[String,AnyRef]].getOrElse("interval",None).asInstanceOf[Map[String,AnyRef]]
val intervalStartDateUpd = intervalUpd.updated("startDate",requestParamsBody.get("start_date"))
val updatedDateRange = reportConf.get("dateRange").get.asInstanceOf[Map[String, AnyRef]] +
("interval" -> intervalStartDateUpd)
reportConf = reportConf ++ Map("dateRange" -> updatedDateRange)
}
if (requestParamsBody.contains("end_date")){
val intervalUpd = reportConf.getOrElse("dateRange",None).asInstanceOf[Map[String,AnyRef]].getOrElse("interval",None).asInstanceOf[Map[String,AnyRef]]
val intervalEndDateUpd = intervalUpd.updated("endDate",requestParamsBody.get("end_date"))
val updatedDateRange = reportConf.get("dateRange").get.asInstanceOf[Map[String, AnyRef]] +
("interval" -> intervalEndDateUpd)
reportConf = reportConf ++ Map("dateRange" -> updatedDateRange)
}
val updatedMetrics:List[Map[String, AnyRef]] = reportConf.getOrElse("metrics", List()).asInstanceOf[List[Map[String,AnyRef]]].map( met => {
val updatedDruidQuery:Map[String,AnyRef] = met.get("druidQuery").get.asInstanceOf[Map[String,AnyRef]] + ("filters"->requestParamsBody.get("filters").get.asInstanceOf[List[Map[String,AnyRef]]])
val updatedMet: Map[String, AnyRef] = (met ++ Map("druidQuery"->updatedDruidQuery))
Expand Down
Loading

0 comments on commit 2a4da07

Please sign in to comment.