prevent colour boosting

This commit is contained in:
Thibault Duplessis 2018-04-30 17:48:48 +02:00
parent df3bd88d19
commit 4f6d6e4360

View file

@ -134,7 +134,11 @@ object UserRepo {
}
def incColor(userId: User.ID, value: Int): Unit =
coll.update($id(userId), $inc(F.colorIt -> value), writeConcern = GetLastError.Unacknowledged)
coll.update(
$id(userId) ++ (value < 0).??($doc("colorIt" $gt -3)),
$inc(F.colorIt -> value),
writeConcern = GetLastError.Unacknowledged
)
def lichess = byId(User.lichessId)