Skip to content

Commit

Permalink
add nation to competition summary model
Browse files Browse the repository at this point in the history
  • Loading branch information
marjisound committed Dec 20, 2024
1 parent 7998a82 commit 6a7bd3b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
5 changes: 3 additions & 2 deletions sport/app/football/controllers/MatchListController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ case class DotcomRenderingFootballDataModel(
pageType: String,
matchesList: Seq[MatchesByDateAndCompetition],
nextPage: Option[String],
previousPage: Option[String],
)

object DotcomRenderingFootballDataModel {
Expand Down Expand Up @@ -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]
Expand Down
1 change: 1 addition & 0 deletions sport/app/football/model/model.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ trait CompetitionSummary {
def url: String
def fullName: String
def shortName: String
def nation: String
}

/** @param tableDividers
Expand Down

0 comments on commit 6a7bd3b

Please sign in to comment.