related user doesn't always have nb games attached

This commit is contained in:
Thibault Duplessis 2016-02-29 09:06:43 +07:00
parent ff451fdbf8
commit f369702747
5 changed files with 8 additions and 6 deletions

View file

@ -99,7 +99,7 @@ object Relation extends LilaController {
(ctx.isAuth ?? { Env.pref.api.followableIds(users map (_.id)) }) flatMap { followables =>
users.map { u =>
ctx.userId ?? { env.api.fetchRelation(_, u.id) } map { rel =>
lila.relation.Related(u, 0, followables(u.id), rel)
lila.relation.Related(u, none, followables(u.id), rel)
}
}.sequenceFu
}

View file

@ -214,7 +214,7 @@ object User extends LilaController {
(ops zip followables).map {
case ((u, nb), followable) => ctx.userId ?? {
relationApi.fetchRelation(_, u.id)
} map { lila.relation.Related(u, nb, followable, _) }
} map { lila.relation.Related(u, nb.some, followable, _) }
}.sequenceFu map { relateds =>
html.user.opponents(user, relateds)
}

View file

@ -7,9 +7,9 @@
<td>@userLink(r.user)</td>
<td>@showBestPerf(r.user)</td>
<td>
@if(r.nbGames > 0) {
@r.nbGames.filter(_ > 0).map { nbGames =>
<a href="@routes.User.showFilter(u.username, "search")?players.b=@r.user.username" class="hint--bottom" data-hint="Games count over your last 1000 games">
@r.nbGames @trans.games()
@nbGames @trans.games()
</a>
}
</td>

View file

@ -1,6 +1,7 @@
package lila.relation
import play.api.libs.json._
import lila.common.PimpedJson._
object JsonView {
@ -10,6 +11,7 @@ object JsonView {
"user" -> r.user,
"nbGames" -> r.nbGames,
"followable" -> r.followable,
"relation" -> r.relation)
"relation" -> r.relation
).noNull
}
}

View file

@ -2,6 +2,6 @@ package lila.relation
case class Related(
user: lila.user.User,
nbGames: Int,
nbGames: Option[Int],
followable: Boolean,
relation: Option[Relation])