fix/weekly cache metrics endpoint#1942
Open
alanpeixinho wants to merge 1 commit into
Open
Conversation
bhcopeland
reviewed
Jun 18, 2026
| ) | ||
| end_datetime = datetime.combine( | ||
| today - timedelta(days=end_days_ago), | ||
| time.max, |
Member
There was a problem hiding this comment.
Trying to work out the SQL below, I think this will be an 8-day window? Because it causes SQL to be at the end of the 7-day window (i.e. on the last day it will be at midnight).
Contributor
Author
There was a problem hiding this comment.
yes, you are correct.
The cached query is happening at the start of the day (just like the mail notification), so the 8th day would end up empty.
But still, it is not robust to rely on time of the call.
fa3d93c to
a580d94
Compare
* Use fixed UTC date bounds for metrics intervals so cache keys stay stable across the week * Expose created_at on the API * Align the dashboard with the email window, and warm the cache after the Saturday metrics email. Closes kernelci#1940 Signed-off-by: Alan Peixinho <alan.peixinho@profusion.mobi>
a580d94 to
6230330
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What it is
Makes the metrics page cache its response for a week, so we can:
How to test:
Test warming cache crontab
poetry run python3 manage.py crontab addpoetry run python3 manage.py crontab showpoetry run python3 manage.py crontab run <hash of cronjob>* It is important to point here that the warm is supposed to run at the same time as email metrics (saturday), so they might not be aligned to the same days as frontend requests.
* Alternatively to this, we could change the system clock.
metricsTotalObjects,metricsBuildIncidents,metricsNewBuildIncidents,metricsLabSummary) (via redis-cli) or via python script.poetry run python3 manage.py crontab removeTesting endpoint
Closes #1940