Skip to content

Commit

Permalink
Merge pull request #303 from gravetii/refactor-unique-method
Browse files Browse the repository at this point in the history
Refactor unique method to use exists without empty string
  • Loading branch information
lenguyenthanh authored Sep 8, 2024
2 parents 2f9a2c9 + 63106dc commit 5f292da
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions modules/ingestor/src/main/scala/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ extension [A](changes: List[ChangeStreamDocument[A]])
def unique: List[ChangeStreamDocument[A]] =
changes
.foldRight(List.empty[ChangeStreamDocument[A]] -> Set.empty) { case (change, p @ (acc, ids)) =>
val id = change.docId.getOrElse("")
if !ids.contains(id) && id != ""
if change.docId.exists(ids.contains)
then (change :: acc) -> (ids + id)
else p
}
Expand Down

0 comments on commit 5f292da

Please sign in to comment.