Skip to content

Include yesterday live matches in our cached data#28885

Merged
marjisound merged 2 commits into
mainfrom
fix-include-yesterday-live-matches
Jun 26, 2026
Merged

Include yesterday live matches in our cached data#28885
marjisound merged 2 commits into
mainfrom
fix-include-yesterday-live-matches

Conversation

@marjisound

@marjisound marjisound commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

What does this change?

This PR updates the refreshMatchDay implementation to prevent losing live match updates when the date boundary changes (midnight). The job now checks if any match in the cache started yesterday but still has isLive = true. If so, it makes an additional PA call to fetch yesterday's matches alongside today's, ensuring we capture score updates for matches that span the date boundary.

How

The implementation:

  1. Calls liveMatchesFromYesterday() to detect live matches from the previous day
  2. If found, fetches both today's and yesterday's match data from PA in parallel
  3. Merges both responses, filtering yesterday's matches to only live ones (avoiding re-adding finished results)
  4. Pushes all merged matches to the competition agents

Known timezone quirk:

PA always returns match data in Europe/London timezone, while the Sport server uses UTC as its default clock. Although ZonedDateTime handles this correctly in most cases, refreshMatchDay uses LocalDate.now(clock) which can cause a one-hour discrepancy during BST (British Summer Time). Specifically, between midnight and 1 AM during summer months, we may fetch yesterday's matches even though technically it's already "today" in London time.
Although this is better to get fixed, I prefer not to do it as part of this PR to minimise the changes and reduce the risk as we are in the middle of the world cup.
Ticket is created for this #28887

Testing

To properly unit test this scenario, I created a testCompetitionsServiceWithMatchDayResponses helper that allows stubbing PA responses for specific dates. This lets us:

  • Control what data PA returns for today vs. yesterday
  • Verify that live matches from yesterday are fetched and merged correctly
  • Confirm that finished results from yesterday are not re-added to the cache

The test validates that:

  • A live match from yesterday with an updated score is refreshed
  • A finished result from yesterday MatchDay is not re-added
  • The final state contains all unique matches (cached + updated yesterday (still live) + new today)

Fixes guardian/dotcom-rendering#16241

This is to avoid losing updates for matches that started yesterday but haven't yet finished
@github-actions

github-actions Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

@marjisound marjisound added the feature Departmental tracking: work on a new feature label Jun 24, 2026
@marjisound marjisound force-pushed the fix-include-yesterday-live-matches branch 2 times, most recently from 0a5b27d to 4c76036 Compare June 26, 2026 07:59
@marjisound marjisound marked this pull request as ready for review June 26, 2026 08:09
@marjisound marjisound requested a review from a team as a code owner June 26, 2026 08:09
val newSummary = newMatch.statusSummary
val oldSummary = oldMatch.statusSummary
if (newSummary != oldSummary) log.debug(s"Match Status Changed $oldSummary -> $newSummary")
if (newSummary != oldSummary) log.info(s"Match Status Changed $oldSummary -> $newSummary")

@marjisound marjisound Jun 26, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed the match status log from DEBUG to INFO level for better visibility during the World Cup. This helps track any unexpected data inconsistencies that might arise. We can revert this to DEBUG after the tournament.

Comment thread sport/test/CompetitionAgentTest.scala Outdated
@marjisound marjisound force-pushed the fix-include-yesterday-live-matches branch from 4c76036 to a674a55 Compare June 26, 2026 12:55

@Jakeii Jakeii left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, nice work finding an efficient solution!

@marjisound marjisound merged commit 47a960a into main Jun 26, 2026
10 checks passed
@marjisound marjisound deleted the fix-include-yesterday-live-matches branch June 26, 2026 13:46
@gu-prout

gu-prout Bot commented Jun 26, 2026

Copy link
Copy Markdown

Seen on ADMIN-PROD (merged by @marjisound 8 minutes and 3 seconds ago)

@gu-prout

gu-prout Bot commented Jun 26, 2026

Copy link
Copy Markdown

Seen on FRONTS-PROD (merged by @marjisound 10 minutes and 16 seconds ago)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature Departmental tracking: work on a new feature Seen-on-ADMIN-PROD Seen-on-FRONTS-PROD

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Outdated football score data in liveblog header, live scores table

3 participants