fix async activity
parent
e8c2316266
commit
f0df082c88
|
@ -58,14 +58,18 @@ object User extends LilaController {
|
|||
)
|
||||
}
|
||||
}
|
||||
private def renderShow(u: UserModel, status: Results.Status = Results.Ok)(implicit ctx: Context) = {
|
||||
for {
|
||||
as <- Env.activity.read.recent(u.id, 7)
|
||||
nbs ← Env.current.userNbGames(u, ctx)
|
||||
info ← Env.current.userInfo(u, nbs, ctx)
|
||||
social ← Env.current.socialInfo(u, ctx)
|
||||
} yield status(html.user.show.activity(u, as, info, social))
|
||||
}.mon(_.http.response.user.show.website)
|
||||
private def renderShow(u: UserModel, status: Results.Status = Results.Ok)(implicit ctx: Context) =
|
||||
if (HTTPRequest.isSynchronousHttp(ctx.req)) {
|
||||
for {
|
||||
as <- Env.activity.read.recent(u.id)
|
||||
nbs ← Env.current.userNbGames(u, ctx)
|
||||
info ← Env.current.userInfo(u, nbs, ctx)
|
||||
social ← Env.current.socialInfo(u, ctx)
|
||||
} yield status(html.user.show.activity(u, as, info, social))
|
||||
}.mon(_.http.response.user.show.website)
|
||||
else Env.activity.read.recent(u.id) map { as =>
|
||||
status(html.activity.list(u, as))
|
||||
}
|
||||
|
||||
def gamesAll(username: String, page: Int) = games(username, GameFilter.All.name, page)
|
||||
|
||||
|
|
|
@ -21,8 +21,10 @@ final class ActivityReadApi(
|
|||
import activities._
|
||||
import model._
|
||||
|
||||
def recent(userId: User.ID, days: Int): Fu[List[ActivityView.AsTo]] = for {
|
||||
as <- coll.byOrderedIds[Activity, Id](makeIds(userId, days))(_.id)
|
||||
private val recentNb = 7
|
||||
|
||||
def recent(userId: User.ID): Fu[List[ActivityView.AsTo]] = for {
|
||||
as <- coll.byOrderedIds[Activity, Id](makeIds(userId, recentNb))(_.id)
|
||||
practiceStructure <- as.exists(_.practice.isDefined) ?? {
|
||||
practiceApi.structure.get map some
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue