From 6a7bd3b5a0428610d0275f4789f0b69d9cf24e3b Mon Sep 17 00:00:00 2001 From: Marjan Kalanaki Date: Fri, 20 Dec 2024 09:56:28 +0000 Subject: [PATCH] add nation to competition summary model --- sport/app/football/controllers/MatchListController.scala | 5 +++-- .../football/model/DotcomRenderingFootballDataModel.scala | 7 ++++--- sport/app/football/model/model.scala | 1 + 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/sport/app/football/controllers/MatchListController.scala b/sport/app/football/controllers/MatchListController.scala index 18c890ac456..1a22fe9a728 100644 --- a/sport/app/football/controllers/MatchListController.scala +++ b/sport/app/football/controllers/MatchListController.scala @@ -36,17 +36,18 @@ trait MatchListController extends BaseController with Requests { pageType = matchesList.pageType, matchesList = DotcomRenderingFootballDataModel.getMatchesList(matchesList.matchesGroupedByDateAndCompetition), nextPage = matchesList.nextPage, + previousPage = matchesList.previousPage, ) JsonComponent.fromWritable(model) - } else if (request.isJson) { + } else if (request.isJson) JsonComponent( "html" -> football.views.html.matchList.matchesComponent(matchesList), "next" -> Html(matchesList.nextPage.getOrElse("")), "previous" -> Html(matchesList.previousPage.getOrElse("")), "atom" -> atom.isDefined, ) - } else + else RevalidatableResult.Ok(football.views.html.matchList.matchesPage(page, matchesList, filters, atom)) } } diff --git a/sport/app/football/model/DotcomRenderingFootballDataModel.scala b/sport/app/football/model/DotcomRenderingFootballDataModel.scala index eb89738bd5a..38b1f401878 100644 --- a/sport/app/football/model/DotcomRenderingFootballDataModel.scala +++ b/sport/app/football/model/DotcomRenderingFootballDataModel.scala @@ -31,6 +31,7 @@ case class DotcomRenderingFootballDataModel( pageType: String, matchesList: Seq[MatchesByDateAndCompetition], nextPage: Option[String], + previousPage: Option[String], ) object DotcomRenderingFootballDataModel { @@ -96,14 +97,14 @@ object DotcomRenderingFootballDataModelImplicits { implicit val leagueTeamWrites: Writes[LeagueTeam] = Json.writes[LeagueTeam] implicit val leagueTableEntryWrites: Writes[LeagueTableEntry] = Json.writes[LeagueTableEntry] - implicit val competitionFormat: Writes[CompetitionSummary] = new Writes[CompetitionSummary] { - def writes(competition: CompetitionSummary): JsValue = Json.obj( + implicit val competitionFormat: Writes[CompetitionSummary] = (competition: CompetitionSummary) => + Json.obj( "id" -> competition.id, "url" -> competition.url, "fullName" -> competition.fullName, "shortName" -> competition.shortName, + "nation" -> competition.nation, ) - } implicit val competitionMatchesFormat: Writes[CompetitionMatches] = Json.writes[CompetitionMatches] implicit val dateCompetitionMatchesFormat: Writes[MatchesByDateAndCompetition] = Json.writes[MatchesByDateAndCompetition] diff --git a/sport/app/football/model/model.scala b/sport/app/football/model/model.scala index 45057f23544..edd5f909991 100644 --- a/sport/app/football/model/model.scala +++ b/sport/app/football/model/model.scala @@ -11,6 +11,7 @@ trait CompetitionSummary { def url: String def fullName: String def shortName: String + def nation: String } /** @param tableDividers