sequence puzzle voting
parent
97525249d6
commit
4da0b71df5
|
@ -13,7 +13,7 @@ final class PuzzleApi(
|
|||
colls: PuzzleColls,
|
||||
trustApi: PuzzleTrustApi,
|
||||
countApi: PuzzleCountApi
|
||||
)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||
)(implicit ec: scala.concurrent.ExecutionContext, system: akka.actor.ActorSystem, mode: play.api.Mode) {
|
||||
|
||||
import Puzzle.{ BSONFields => F }
|
||||
import BsonHandlers._
|
||||
|
@ -44,7 +44,16 @@ final class PuzzleApi(
|
|||
|
||||
object vote {
|
||||
|
||||
private val sequencer =
|
||||
new lila.hub.DuctSequencers(
|
||||
maxSize = 16,
|
||||
expiration = 5 minutes,
|
||||
timeout = 3 seconds,
|
||||
name = "puzzle.vote"
|
||||
)
|
||||
|
||||
def update(id: Puzzle.Id, user: User, vote: Boolean): Funit =
|
||||
sequencer(id.value) {
|
||||
round
|
||||
.find(user, id)
|
||||
.flatMap {
|
||||
|
@ -61,6 +70,7 @@ final class PuzzleApi(
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private def updatePuzzle(puzzleId: Puzzle.Id, newVote: Int, prevVote: Option[Int]): Funit =
|
||||
colls.puzzle { coll =>
|
||||
|
|
Loading…
Reference in New Issue