Skip to content

Commit

Permalink
optimize player and watcher pages performances
Browse files Browse the repository at this point in the history
  • Loading branch information
ornicar committed Oct 25, 2012
1 parent 922dac5 commit 439f74e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
13 changes: 4 additions & 9 deletions app/controllers/Round.scala
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,16 @@ 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) {
Ok(html.round.player(
pov,
version(pov.gameId),
engine,
roomHtml map { Html(_) },
roomHtml map Html.apply,
bookmarkers,
analysed,
tour = tour))
Expand All @@ -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
Expand Down
7 changes: 2 additions & 5 deletions app/user/UserRepo.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down

0 comments on commit 439f74e

Please sign in to comment.