Skip to content

Commit

Permalink
Merge pull request #300 from lichess-org/index-forums-with-update-event
Browse files Browse the repository at this point in the history
Index forum posts in update events
  • Loading branch information
lenguyenthanh authored Sep 2, 2024
2 parents d610e81 + 52611d6 commit 25e5806
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion modules/ingestor/src/main/scala/ingestor.forum.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package ingestor

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

private val index = Index.Forum

private val interestedOperations = List(DELETE, INSERT, REPLACE).map(_.getValue)
private val interestedOperations = List(DELETE, INSERT, REPLACE, UPDATE).map(_.getValue)

private def maxPostSizeFilter(max: Int) =
Filter.expr(s"{ $$lte: [{ $$strLenCP: '$$fullDocument.text' }, $max] }")
Expand Down Expand Up @@ -117,6 +118,7 @@ object ForumIngestor:
val skip = since.fold(0)(_ => 1)
since
.fold(builder)(x => builder.startAtOperationTime(x.asBsonTimestamp))
.fullDocument(FullDocument.UPDATE_LOOKUP) // this is required for update event
.batchSize(config.batchSize)
.boundedStream(config.batchSize)
.drop(skip)
Expand Down

0 comments on commit 25e5806

Please sign in to comment.