remove unused field from game API JSON
This commit is contained in:
parent
749388b49a
commit
0b8be4b4db
|
@ -53,7 +53,7 @@ final class JsonView(
|
|||
"color" -> player.color.name,
|
||||
"version" -> socket.version,
|
||||
"spectator" -> false,
|
||||
"user" -> playerUser.map { userJsonView(_, game.perfType) },
|
||||
"user" -> playerUser.map { userJsonView.minimal(_, game.perfType) },
|
||||
"rating" -> player.rating,
|
||||
"ratingDiff" -> player.ratingDiff,
|
||||
"provisional" -> player.provisional.option(true),
|
||||
|
@ -69,7 +69,7 @@ final class JsonView(
|
|||
"opponent" -> Json.obj(
|
||||
"color" -> opponent.color.name,
|
||||
"ai" -> opponent.aiLevel,
|
||||
"user" -> opponentUser.map { userJsonView(_, game.perfType) },
|
||||
"user" -> opponentUser.map { userJsonView.minimal(_, game.perfType) },
|
||||
"rating" -> opponent.rating,
|
||||
"ratingDiff" -> opponent.ratingDiff,
|
||||
"provisional" -> opponent.provisional.option(true),
|
||||
|
@ -148,7 +148,7 @@ final class JsonView(
|
|||
"version" -> socket.version,
|
||||
"spectator" -> true,
|
||||
"ai" -> player.aiLevel,
|
||||
"user" -> playerUser.map { userJsonView(_, game.perfType) },
|
||||
"user" -> playerUser.map { userJsonView.minimal(_, game.perfType) },
|
||||
"name" -> player.name.map(escapeHtml4),
|
||||
"rating" -> player.rating,
|
||||
"ratingDiff" -> player.ratingDiff,
|
||||
|
@ -162,7 +162,7 @@ final class JsonView(
|
|||
"opponent" -> Json.obj(
|
||||
"color" -> opponent.color.name,
|
||||
"ai" -> opponent.aiLevel,
|
||||
"user" -> opponentUser.map { userJsonView(_, game.perfType) },
|
||||
"user" -> opponentUser.map { userJsonView.minimal(_, game.perfType) },
|
||||
"name" -> opponent.name.map(escapeHtml4),
|
||||
"rating" -> opponent.rating,
|
||||
"ratingDiff" -> opponent.ratingDiff,
|
||||
|
@ -248,7 +248,7 @@ final class JsonView(
|
|||
"turns" -> game.turns,
|
||||
"startedAtTurn" -> game.startedAtTurn,
|
||||
"lastMove" -> game.castleLastMoveTime.lastMoveString,
|
||||
"threefold" -> game.toChessHistory.threefoldRepetition,
|
||||
"threefold" -> game.toChessHistory.threefoldRepetition.option(true),
|
||||
"check" -> game.check.map(_.key),
|
||||
"rematch" -> game.next,
|
||||
"source" -> game.source.map(sourceJson),
|
||||
|
@ -315,8 +315,7 @@ object JsonView {
|
|||
Json.obj(
|
||||
"key" -> v.key,
|
||||
"name" -> v.name,
|
||||
"short" -> v.shortName,
|
||||
"title" -> v.title)
|
||||
"short" -> v.shortName)
|
||||
}
|
||||
|
||||
implicit val statusWriter: OWrites[chess.Status] = OWrites { s =>
|
||||
|
|
|
@ -16,15 +16,26 @@ final class JsonView(isOnline: String => Boolean) {
|
|||
"username" -> u.username,
|
||||
"title" -> u.title,
|
||||
"online" -> isOnline(u.id),
|
||||
"engine" -> u.engine,
|
||||
"booster" -> u.booster,
|
||||
"engine" -> u.engine.option(true),
|
||||
"booster" -> u.booster.option(true),
|
||||
"language" -> u.lang,
|
||||
"profile" -> u.profile.??(profileWrites.writes).noNull,
|
||||
"perfs" -> perfs(u, onlyPerf),
|
||||
"createdAt" -> u.createdAt,
|
||||
"seenAt" -> u.seenAt,
|
||||
"playTime" -> u.playTime,
|
||||
"patron" -> u.isPatron
|
||||
"patron" -> u.isPatron.option(true)
|
||||
).noNull
|
||||
|
||||
def minimal(u: User, onlyPerf: Option[PerfType]) = Json.obj(
|
||||
"id" -> u.id,
|
||||
"username" -> u.username,
|
||||
"title" -> u.title,
|
||||
"online" -> isOnline(u.id),
|
||||
"engine" -> u.engine.option(true),
|
||||
"booster" -> u.booster.option(true),
|
||||
"perfs" -> perfs(u, onlyPerf),
|
||||
"patron" -> u.isPatron.option(true)
|
||||
).noNull
|
||||
|
||||
def lightPerfIsOnline(lp: LightPerf) = {
|
||||
|
|
Loading…
Reference in a new issue