Skip to content

Commit

Permalink
Fix addinfo representation in JSON
Browse files Browse the repository at this point in the history
  • Loading branch information
dkttarento committed Jan 8, 2024
1 parent 56ae86f commit 7baebda
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ class CourseEnrolmentActor @Inject()(@Named("course-batch-notification-actor") c
var certificateIssued: Int = 0
var coursesInProgress: Int = 0
var hoursSpentOnCompletedCourses: Int = 0
var addInfo: util.Map[String, AnyRef] = null
var addInfo: util.Map[String, AnyRef] = new util.HashMap[String, AnyRef]()
finalEnrolment.foreach { courseDetails =>
val courseStatus = courseDetails.get(JsonKey.STATUS)
if (courseStatus != 2) {
Expand Down Expand Up @@ -676,11 +676,11 @@ class CourseEnrolmentActor @Inject()(@Named("course-batch-notification-actor") c
record.get(JsonKey.USER_KARMA_TOTAL_POINTS).asInstanceOf[Integer].toInt
}.getOrElse(0)
val addInfoString: String = if (dbResponse.isEmpty) {
null
""
} else {
dbResponse.get(0).get(JsonKey.ADD_INFO).asInstanceOf[String]
Option(dbResponse.get(0)).flatMap(record => Option(record.get(JsonKey.ADD_INFO)).collect { case str: String => str }).getOrElse("")
}
if (addInfoString != null) {
if (addInfoString != null && addInfoString.nonEmpty) {
val objectMapper = new ObjectMapper().registerModule(DefaultScalaModule)
addInfo = objectMapper.readValue(addInfoString, classOf[util.Map[String, AnyRef]])
}
Expand Down

0 comments on commit 7baebda

Please sign in to comment.