better pool json
This commit is contained in:
parent
91e6c051b7
commit
b661f196bc
|
@ -15,9 +15,7 @@ object Lobby extends LilaController {
|
||||||
private val lobbyJson = Json.obj(
|
private val lobbyJson = Json.obj(
|
||||||
"lobby" -> Json.obj(
|
"lobby" -> Json.obj(
|
||||||
"version" -> 0,
|
"version" -> 0,
|
||||||
"pool" -> Json.obj(
|
"pools" -> Env.api.lobbyApi.poolsJson
|
||||||
"list" -> lila.pool.PoolList.all.map(_.clock.show)
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -16,16 +16,9 @@ final class LobbyApi(
|
||||||
pools: List[lila.pool.PoolConfig]) {
|
pools: List[lila.pool.PoolConfig]) {
|
||||||
|
|
||||||
import makeTimeout.large
|
import makeTimeout.large
|
||||||
|
import lila.pool.JsonView._
|
||||||
|
|
||||||
private val poolsJson = JsArray {
|
val poolsJson = Json toJson pools
|
||||||
pools.map { p =>
|
|
||||||
Json.obj(
|
|
||||||
"id" -> p.id.value,
|
|
||||||
"lim" -> p.clock.limitInMinutes,
|
|
||||||
"inc" -> p.clock.increment,
|
|
||||||
"perf" -> p.perfType.name)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def apply(implicit ctx: Context): Fu[JsObject] =
|
def apply(implicit ctx: Context): Fu[JsObject] =
|
||||||
ctx.me.fold(seekApi.forAnon)(seekApi.forUser) zip
|
ctx.me.fold(seekApi.forAnon)(seekApi.forUser) zip
|
||||||
|
|
14
modules/pool/src/main/JsonView.scala
Normal file
14
modules/pool/src/main/JsonView.scala
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
package lila.pool
|
||||||
|
|
||||||
|
import play.api.libs.json._
|
||||||
|
|
||||||
|
object JsonView {
|
||||||
|
|
||||||
|
implicit val poolConfigJsonWriter = OWrites[PoolConfig] { p =>
|
||||||
|
Json.obj(
|
||||||
|
"id" -> p.id.value,
|
||||||
|
"lim" -> p.clock.limitInMinutes,
|
||||||
|
"inc" -> p.clock.increment,
|
||||||
|
"perf" -> p.perfType.name)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue