Skip to content

Commit

Permalink
Correct reason log reason when topic is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
lenguyenthanh committed Jun 21, 2024
1 parent a94fba6 commit bdfe556
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions modules/ingestor/src/main/scala/ingestor.forum.scala
Original file line number Diff line number Diff line change
Expand Up @@ -157,17 +157,19 @@ object ForumIngestor:
case _ =>
val reason = doc._id.fold("missing doc._id; ")(_ => "")
+ doc.topicId.fold("missing doc.topicId; ")(_ => "")
+ doc.topicId
.map(id => topicMap.get(id).fold("topic or topicName is missing")(_ => ""))
.getOrElse("")
info"failed to convert document to source: $doc because $reason".as(none)

private def toSource(topicName: Option[String], topicId: String): Option[ForumSource] =
(
doc.getString("text").map(_.take(config.maxBodyLength)),
topicName,
topicId.some,
doc.getBoolean("troll"),
doc.getNested("createdAt").flatMap(_.asInstant).map(_.toEpochMilli()),
doc.getString("userId").some
).mapN(ForumSource.apply)
).mapN(ForumSource.apply(_, _, topicId, _, _, _))

private def isErased: Boolean =
doc.get("erasedAt").isDefined
Expand Down

0 comments on commit bdfe556

Please sign in to comment.