optimize player and watcher pages performances
This commit is contained in:
parent
922dac599f
commit
439f74ec29
|
@ -56,10 +56,8 @@ object Round extends LilaController with TheftPrevention with RoundEventPerforme
|
|||
pov.game.started.fold(
|
||||
for {
|
||||
roomHtml ← messenger render pov.game
|
||||
bookmarkers ← bookmarkApi usersByGame pov.game
|
||||
engine ← pov.opponent.userId.fold(
|
||||
u ⇒ userRepo isEngine u,
|
||||
io(false))
|
||||
bookmarkers ← pov.game.hasBookmarks.fold(bookmarkApi usersByGame pov.game, io(Nil))
|
||||
engine ← pov.opponent.userId.fold(userRepo.isEngine, io(false))
|
||||
analysed ← analyser has pov.gameId
|
||||
tour ← tournamentRepo byId pov.game.tournamentId
|
||||
} yield PreventTheft(pov) {
|
||||
|
@ -67,7 +65,7 @@ object Round extends LilaController with TheftPrevention with RoundEventPerforme
|
|||
pov,
|
||||
version(pov.gameId),
|
||||
engine,
|
||||
roomHtml map { Html(_) },
|
||||
roomHtml map Html.apply,
|
||||
bookmarkers,
|
||||
analysed,
|
||||
tour = tour))
|
||||
|
@ -90,10 +88,7 @@ object Round extends LilaController with TheftPrevention with RoundEventPerforme
|
|||
}
|
||||
|
||||
private def watch(pov: Pov)(implicit ctx: Context): IO[Result] = for {
|
||||
bookmarkers ← pov.game.hasBookmarks.fold(
|
||||
bookmarkApi usersByGame pov.game,
|
||||
io(Nil)
|
||||
)
|
||||
bookmarkers ← pov.game.hasBookmarks.fold(bookmarkApi usersByGame pov.game, io(Nil))
|
||||
roomHtml ← messenger renderWatcher pov.game
|
||||
analysed ← analyser has pov.gameId
|
||||
tour ← tournamentRepo byId pov.game.tournamentId
|
||||
|
|
|
@ -168,11 +168,8 @@ class UserRepo(collection: MongoCollection)
|
|||
}
|
||||
|
||||
def isEngine(username: String): IO[Boolean] = io {
|
||||
for {
|
||||
obj ← collection.findOne(byIdQuery(username), DBObject("engine" -> true))
|
||||
engine ← obj.getAs[Boolean]("engine")
|
||||
} yield engine
|
||||
} map (_ | false)
|
||||
collection.find(byIdQuery(username) ++ DBObject("engine" -> true)).size != 0
|
||||
}
|
||||
|
||||
def setBio(user: User, bio: String) = updateIO(user)($set("bio" -> bio))
|
||||
|
||||
|
|
Loading…
Reference in a new issue