@@ -29,7 +29,6 @@ import play.api.libs.json._
2929import play .api .mvc .RequestHeader
3030import views .support .{CamelCase , JavaScriptPage }
3131import ab .ABTests
32- import football .model .DotcomRenderingFootballTablesDataModel .getEntries
3332
3433import java .time .LocalDate
3534import java .time .format .DateTimeFormatter
@@ -144,20 +143,6 @@ private object DotcomRenderingFootballDataModelImplicits {
144143 Json .writes[MatchesByDateAndCompetition ]
145144
146145 implicit val competitionFilterFormat : Writes [CompetitionFilter ] = Json .writes[CompetitionFilter ]
147-
148- implicit val tableWrites : Writes [Table ] = (table : Table ) =>
149- withoutDeepNull(
150- Json .obj(
151- " competition" -> Json .toJson(table.competition: CompetitionSummary ),
152- " groups" -> table.groups.map { group =>
153- Json .obj(
154- " round" -> group.round,
155- " entries" -> getEntries(table.competition, group),
156- )
157- },
158- " hasGroups" -> table.multiGroup,
159- ),
160- )
161146}
162147
163148case class DotcomRenderingFootballMatchListDataModel (
@@ -288,7 +273,7 @@ object DotcomRenderingFootballTablesDataModel {
288273
289274 import football .model .DotcomRenderingFootballDataModelImplicits ._
290275
291- def getEntries (competition : Competition , group : Group ): Seq [JsObject ] = {
276+ private def getEntries (competition : Competition , group : Group ): Seq [JsObject ] = {
292277 group.entries.map { entry =>
293278 Json .obj(
294279 " stageNumber" -> entry.stageNumber,
@@ -312,7 +297,20 @@ object DotcomRenderingFootballTablesDataModel {
312297
313298 private implicit val teamScoreFormat : Writes [TeamScore ] = Json .writes[TeamScore ]
314299 private implicit val teamResultFormat : Writes [TeamResult ] = Json .writes[TeamResult ]
315- private implicit val groupFormat : Writes [Group ] = Json .writes[Group ]
300+
301+ private implicit val tableWrites : Writes [Table ] = (table : Table ) =>
302+ withoutDeepNull(
303+ Json .obj(
304+ " competition" -> Json .toJson(table.competition: CompetitionSummary ),
305+ " groups" -> table.groups.map { group =>
306+ Json .obj(
307+ " round" -> group.round,
308+ " entries" -> getEntries(table.competition, group),
309+ )
310+ },
311+ " hasGroups" -> table.multiGroup,
312+ ),
313+ )
316314
317315 implicit def dotcomRenderingFootballTablesDataModel : Writes [DotcomRenderingFootballTablesDataModel ] =
318316 Json .writes[DotcomRenderingFootballTablesDataModel ]
@@ -325,7 +323,7 @@ object DotcomRenderingFootballTablesDataModel {
325323
326324case class DotcomRenderingFootballMatchSummaryDataModel (
327325 footballMatch : MatchDataAnswer ,
328- table : Option [Table ],
326+ group : Option [Group ],
329327 nav : Nav ,
330328 editionId : String ,
331329 guardianBaseURL : String ,
@@ -341,7 +339,7 @@ object DotcomRenderingFootballMatchSummaryDataModel {
341339 def apply (
342340 page : MatchPage ,
343341 footballMatch : MatchDataAnswer ,
344- table : Option [Table ],
342+ group : Option [Group ],
345343 )(implicit
346344 request : RequestHeader ,
347345 context : ApplicationContext ,
@@ -351,7 +349,7 @@ object DotcomRenderingFootballMatchSummaryDataModel {
351349 val combinedConfig : JsObject = DotcomRenderingFootballDataModel .getConfig(page)
352350 DotcomRenderingFootballMatchSummaryDataModel (
353351 footballMatch = footballMatch,
354- table = table ,
352+ group = group ,
355353 nav = nav,
356354 editionId = edition.id,
357355 guardianBaseURL = Configuration .site.host,
@@ -366,6 +364,22 @@ object DotcomRenderingFootballMatchSummaryDataModel {
366364
367365 import football .model .DotcomRenderingFootballDataModelImplicits ._
368366
367+ private def getGroupEntries (group : Group ): Seq [JsObject ] = {
368+ group.entries.map { entry =>
369+ Json .obj(
370+ " stageNumber" -> entry.stageNumber,
371+ " round" -> entry.round,
372+ " team" -> entry.team,
373+ " teamUrl" -> TeamUrl (entry.team),
374+ )
375+ }
376+ }
377+ implicit val groupWrites : Writes [Group ] = (group : Group ) =>
378+ Json .obj(
379+ " round" -> group.round,
380+ " entries" -> getGroupEntries(group),
381+ )
382+
369383 implicit def dotcomRenderingFootballMatchSummaryDataModel : Writes [DotcomRenderingFootballMatchSummaryDataModel ] =
370384 Json .writes[DotcomRenderingFootballMatchSummaryDataModel ]
371385
0 commit comments