Skip to content

Commit

Permalink
clamp puzzle votes in case of puzzle/round inconsistency (closes lich…
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasf committed Mar 19, 2023
1 parent 52a1325 commit f30c936
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions modules/puzzle/src/main/PuzzleApi.scala
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ final class PuzzleApi(
) flatMapz { doc =>
val prevUp = ~doc.int(F.voteUp)
val prevDown = ~doc.int(F.voteDown)
val up = prevUp + ~newVote.some.filter(0 <) - ~prevVote.filter(0 <)
val down = prevDown - ~newVote.some.filter(0 >) + ~prevVote.filter(0 >)
val up = (prevUp + ~newVote.some.filter(0 <) - ~prevVote.filter(0 <)) atLeast newVote
val down = (prevDown - ~newVote.some.filter(0 >) + ~prevVote.filter(0 >)) atLeast -newVote
coll.update
.one(
$id(puzzleId),
Expand Down

0 comments on commit f30c936

Please sign in to comment.