remove pairings when a cheater is booted of an ongoing tournament

closes #1387
This commit is contained in:
Thibault Duplessis 2016-01-12 12:02:49 +07:00
parent a40c0d3836
commit 47210cc181
2 changed files with 4 additions and 0 deletions

View file

@ -57,6 +57,9 @@ object PairingRepo {
def removeByTour(tourId: String) = coll.remove(selectTour(tourId)).void
def removeByTourAndUserId(tourId: String, userId: String) =
coll.remove(selectTour(tourId) ++ selectUser(userId)).void
def count(tourId: String): Fu[Int] =
coll.count(selectTour(tourId).some)

View file

@ -225,6 +225,7 @@ private[tournament] final class TournamentApi(
def ejectLame(tourId: String, userId: String) {
Sequencing(tourId)(TournamentRepo.byId) { tour =>
PlayerRepo.remove(tour.id, userId) >>
(tour.isStarted ?? PairingRepo.removeByTourAndUserId(tour.id, userId)) >>
updateNbPlayers(tour.id) >>-
socketReload(tour.id) >>- publish()
}