Adding game completion percentage to user API
This commit is contained in:
parent
5d938e2b60
commit
40c8111895
|
@ -39,14 +39,17 @@ private[api] final class UserApi(
|
|||
ctx.userId.?? { relationApi.fetchFollows(u.id, _) } zip
|
||||
bookmarkApi.countByUser(u) zip
|
||||
gameCache.nbPlaying(u.id) zip
|
||||
gameCache.nbImportedBy(u.id) map {
|
||||
case gameOption ~ nbGamesWithMe ~ following ~ followers ~ followable ~ relation ~ isFollowed ~ nbBookmarks ~ nbPlaying ~ nbImported =>
|
||||
gameCache.nbImportedBy(u.id) zip
|
||||
lila.playban.Env.current.api.completionRate(u.id).map(_.map { cr => math.round(cr * 100) }.getOrElse(0)) map
|
||||
{
|
||||
case gameOption ~ nbGamesWithMe ~ following ~ followers ~ followable ~ relation ~ isFollowed ~ nbBookmarks ~ nbPlaying ~ nbImported ~ completionRate =>
|
||||
jsonView(u) ++ {
|
||||
Json.obj(
|
||||
"url" -> makeUrl(s"@/$username"),
|
||||
"playing" -> gameOption.map(g => makeUrl(s"${g.gameId}/${g.color.name}")),
|
||||
"nbFollowing" -> following,
|
||||
"nbFollowers" -> followers,
|
||||
"completionRate" -> completionRate.asInstanceOf[Int],
|
||||
"count" -> Json.obj(
|
||||
"all" -> u.count.game,
|
||||
"rated" -> u.count.rated,
|
||||
|
|
Loading…
Reference in a new issue