Add shift-column auto-update tooling and recompute logbook shift totals - #267
Add shift-column auto-update tooling and recompute logbook shift totals#267jgray-19 wants to merge 10 commits into
Conversation
Extract the shift-timing logic and CERN holiday list from shift_calculations.py into a new pure-stdlib shift_model.py, so it can be reused without matplotlib/pandas. shift_calculations.py now imports the model for plotting; add update_shift_column.py to recompute the Shifts column of a logbook table from its start/end dates. Interpret all times in Europe/Zurich (tz-aware datetimes) and list the CERN holidays as ISO date strings grouped by source. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ETmmvky8DVfjD6wBwB85dv
There was a problem hiding this comment.
I'm okay with the addition, but felt like being an annoying bitch somehow.
I realised half way through review that my comments were on some pre-existing but moved around code. However, wouldn't that be the opportunity to improve said code?
To be discussed: we could take the opportunity to get rid of the pie charts too? They are horrible for the human brain and can't do a thing that bar charts would do, better represented.
|
Hey, just saw this. If I understand this correctly, this goes against what the shift-column was supposed to be: a representation of the time actually worked, which might be different from start/end times, e.g. if there was a long interruption due to downtime. Ewen didn't want to have this calculated into the plots he presents. That's why the python scripts had the option to calculate from either start/end times or from the shift column. Calculating the shift durations from the start/end times kind of also makes one of the two columns redundant. There were supposed to represent two different kinds of time metrics. |
Yes this is pretty much the discussion that happened in the comments of #268. This PR is very much on hold I would say. |
|
Ohh, thanks for the llink. Didn't see this discussion. And I don't think an extra "shifts" column (as @jgray-19 envisions it) is useful, as a) it doesn't add new information (that's already in the start/end time) |
Summary
Refactors the shift-timing logic into a shared, dependency-free core and adds a
script that recomputes the
Shiftscolumn of any logbook table directly from itsStart Date/End Datecolumns. All existing logbook tables have been regeneratedwith this tool so the recorded shift breakdowns are consistent and reproducible.
Changes
Tooling
scripts/shift_model.py(new) — single source of truth for the shift model(work hours 08:30–17:30, calendar weekends, CERN public holidays, 8h = 1 shift).
Pure standard library, so it can be reused without matplotlib/pandas. All times
are timezone-aware (
Europe/Zurich); holidays are listed as ISO dates grouped bysource. Includes unit tests.
scripts/update_shift_column.py(new) — recomputes and rewrites theShiftscolumn of a logbook markdown table in place. Supports
--check(dry-run, non-zeroexit if stale — handy for CI/pre-commit) and
--selftest. Only touches the firsttable in a file and preserves all surrounding content.
scripts/shift_calculations.py— slimmed down to the reporting/plotting layer;now imports the model from
shift_model.pyinstead of redefining it. Also fixes anincorrect CERN holiday list (stale/duplicated dates).
Data
Shiftscolumn across all logbook tables by running the tool overdocs/logbook/*/*.md(LHC/PS/PSB/SPS, 2022–2026).Usage