only load full tourney in round view if user is participating (mini-standing)
This commit is contained in:
parent
204ed58fbc
commit
4b3b7dd9ef
|
@ -59,7 +59,7 @@ object Round extends LilaController with TheftPrevention {
|
|||
if (pov.game.playableByAi) env.roundMap ! Tell(pov.game.id, AiPlay)
|
||||
pov.game.started.fold(
|
||||
PreventTheft(pov) {
|
||||
(pov.game.tournamentId ?? TournamentRepo.byId) zip
|
||||
myTour(pov.game.tournamentId) zip
|
||||
(pov.game.simulId ?? Env.simul.repo.find) zip
|
||||
Env.game.crosstableApi(pov.game) zip
|
||||
(!pov.game.isTournament ?? otherPovs(pov.gameId)) flatMap {
|
||||
|
@ -145,7 +145,7 @@ object Round extends LilaController with TheftPrevention {
|
|||
else ctx.userId.flatMap(pov.game.playerByUserId) ifTrue pov.game.playable match {
|
||||
case Some(player) => renderPlayer(pov withColor player.color)
|
||||
case None if HTTPRequest.isHuman(ctx.req) =>
|
||||
(pov.game.tournamentId ?? TournamentRepo.byId) zip
|
||||
myTour(pov.game.tournamentId) zip
|
||||
(pov.game.simulId ?? Env.simul.repo.find) zip
|
||||
Env.game.crosstableApi(pov.game) zip
|
||||
Env.api.roundApi.watcher(pov, lila.api.Mobile.Api.currentVersion, tv = none) map {
|
||||
|
@ -163,6 +163,13 @@ object Round extends LilaController with TheftPrevention {
|
|||
api = apiVersion => Env.api.roundApi.watcher(pov, apiVersion, tv = none) map { Ok(_) }
|
||||
)
|
||||
|
||||
private def myTour(tourId: Option[String])(implicit ctx: Context): Fu[Option[Tourney]] =
|
||||
tourId ?? { tid =>
|
||||
ctx.userId ?? { uid =>
|
||||
TournamentRepo.byIdAndPlayerId(tid, uid)
|
||||
}
|
||||
}
|
||||
|
||||
private def join(pov: Pov)(implicit ctx: Context): Fu[Result] =
|
||||
GameRepo initialFen pov.game zip
|
||||
Env.api.roundApi.watcher(pov, lila.api.Mobile.Api.currentVersion, tv = none) zip
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
@(pov: Pov, initialFen: Option[String], tour: Option[lila.tournament.Tournament], withTourStanding: Boolean, simul: Option[lila.simul.Simul], userTv: Option[User] = None)(implicit ctx: Context)
|
||||
@(pov: Pov, initialFen: Option[String], myTour: Option[lila.tournament.Tournament], withTourStanding: Boolean, simul: Option[lila.simul.Simul], userTv: Option[User] = None)(implicit ctx: Context)
|
||||
|
||||
@import pov._
|
||||
@import lila.tournament.arena
|
||||
|
@ -86,7 +86,7 @@
|
|||
</div>
|
||||
}
|
||||
|
||||
@tour match {
|
||||
@myTour match {
|
||||
case Some(t: lila.tournament.StartedOrFinished) => { @tournament.gameStanding(t, withTourStanding) }
|
||||
case _ => {}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,11 @@ object TournamentRepo {
|
|||
|
||||
def byId(id: String): Fu[Option[Tournament]] = coll.find(selectId(id)).one[Tournament]
|
||||
|
||||
def byIdAndPlayerId(id: String, userId: String): Fu[Option[Tournament]] =
|
||||
coll.find(
|
||||
selectId(id) ++ BSONDocument("players.id" -> userId)
|
||||
).one[Tournament]
|
||||
|
||||
def roundView(id: String): Fu[Option[RoundTournament]] =
|
||||
coll.find(selectId(id)).one[RoundTournament]
|
||||
|
||||
|
|
Loading…
Reference in a new issue