Skip to content

Commit

Permalink
Include update & delete event to our change stream
Browse files Browse the repository at this point in the history
  • Loading branch information
lenguyenthanh committed Jun 17, 2024
1 parent 53d254d commit 3a23293
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions modules/ingestor/src/main/scala/ingestor.forum.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package ingestor

import cats.effect.IO
import cats.syntax.all.*
import com.mongodb.client.model.changestream.OperationType
import com.mongodb.client.model.changestream.OperationType.*
import lila.search.spec.ForumSource
import mongo4cats.bson.Document
import mongo4cats.database.MongoDatabase
Expand All @@ -22,7 +22,8 @@ object ForumIngestor:

private val topicProjection = Projection.include(List("_id", "name"))

private val eventFilter = Filter.in("operationType", List("replace", "insert"))
val interestedOperations = List(DELETE, INSERT, UPDATE, REPLACE).map(_.getValue)
private val eventFilter = Filter.in("operationType", interestedOperations)
private val eventProjection = Projection.include(
List(
"documentKey._id",
Expand Down Expand Up @@ -124,5 +125,5 @@ object ForumIngestor:
private def topicId = event.fullDocument.flatMap(_.getString("topicId"))

private def isDelete: Boolean =
event.operationType == OperationType.DELETE ||
event.operationType == DELETE ||
event.fullDocument.flatMap(_.get("erasedAt")).isDefined

0 comments on commit 3a23293

Please sign in to comment.