-
-
Notifications
You must be signed in to change notification settings - Fork 34
add offliner definition version to schedule history entry #1540
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1540 +/- ##
=======================================
Coverage 83.37% 83.38%
=======================================
Files 91 91
Lines 4392 4394 +2
Branches 468 468
=======================================
+ Hits 3662 3664 +2
Misses 608 608
Partials 122 122 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
...rc/zimfarm_backend/migrations/versions/8b0210f9d9ab_store_offliner_definition_version_in_.py
Show resolved
Hide resolved
benoit74
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doing the update of latest existing history entry in a single SQL statement would be better (faster to execute since purely DB, probably less risk of edge cases).
Please confirm, but I feel like this would do the trick:
UPDATE schedule_history sh
SET offliner_definition_version = od.version
FROM schedule s
JOIN offliner_definition od
ON s.offliner_definition_id = od.id
JOIN (
SELECT DISTINCT ON (schedule_id)
id AS history_id, schedule_id
FROM schedule_history
ORDER BY schedule_id, created_at DESC
) latest
ON latest.history_id = sh.id
WHERE sh.schedule_id = s.id;
|
It didn't work because the subquery re-selects from Fixed it by using a CTE instead |
benoit74
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you!
8069e9e to
2f56b64
Compare
Rationale
By adding the offliner definition version to the schedule history entry, we can see the changes to the version recorded in the history.
Changes
This closes #1539