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(
|
||||
"lobby" -> Json.obj(
|
||||
"version" -> 0,
|
||||
"pool" -> Json.obj(
|
||||
"list" -> lila.pool.PoolList.all.map(_.clock.show)
|
||||
)
|
||||
"pools" -> Env.api.lobbyApi.poolsJson
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
@ -16,16 +16,9 @@ final class LobbyApi(
|
|||
pools: List[lila.pool.PoolConfig]) {
|
||||
|
||||
import makeTimeout.large
|
||||
import lila.pool.JsonView._
|
||||
|
||||
private val poolsJson = JsArray {
|
||||
pools.map { p =>
|
||||
Json.obj(
|
||||
"id" -> p.id.value,
|
||||
"lim" -> p.clock.limitInMinutes,
|
||||
"inc" -> p.clock.increment,
|
||||
"perf" -> p.perfType.name)
|
||||
}
|
||||
}
|
||||
val poolsJson = Json toJson pools
|
||||
|
||||
def apply(implicit ctx: Context): Fu[JsObject] =
|
||||
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