Skip to content

feat: replace unedited rows when converting legacy responsibilities again - #220

Draft
tabedzki wants to merge 1 commit into
tabedzki/feat/convert-writes-historicfrom
tabedzki/feat/convert-replace-unedited
Draft

tabedzki wants to merge 1 commit into
tabedzki/feat/convert-writes-historicfrom
tabedzki/feat/convert-replace-unedited

Conversation

@tabedzki

Copy link
Copy Markdown
Contributor

🤖 AI text below 🤖

Stacked on #208 (history rows and the readable report); merge that first.

Problem

convert_legacy_responsibilities.py skips every subject that already has an action.ResponsibilitiesAlt row. Running it again just before the switch to explicit would keep the rows from the first run, even where the live schedule or status has changed since.

Change

python scripts/convert_legacy_responsibilities.py --replace-unedited-since 2026-10-16           # dry run
python scripts/convert_legacy_responsibilities.py --replace-unedited-since 2026-10-16 --write

The date is the day the earlier conversion ran. Without the option, the script behaves as before.

Subject What happens
No row yet insert, as before
Newest ResponsibilitiesAltHistoric row is on or before the date, and the conversion differs replace
Same, but nothing would change skip: already up to date
Saved on the website after the date skip: saved since the earlier conversion
Can't be converted, or is no longer living Its row stays as it is
  • Backup: --write first saves the rows it will replace to a new CSV (--backup), and refuses to overwrite an existing one.
  • All or nothing: both tables are written in one transaction. History rows are only added, never changed.
  • Race check: it checks again inside the transaction and writes nothing if someone saved one of the subjects after the rows were first read. A short window between that check and the commit remains.
  • Today is safe: the date must be before today.

Limit: a website save made on the date itself looks the same as the earlier conversion, so it would be replaced.

Evidence

  • Unit tests: 31 new cases cover the cutoff, rows with no history, saves planned for later, MySQL float rounding, JSON formatting, status-only changes, conversion errors, manual weekdays, the arguments and the backup. uv run pytest: 752 passed, 7 skipped. uvx prek run --all-files is clean.
  • Real writes, throwaway MariaDB 10.11 container: replaced, added and kept rows, history and backup contents, running it twice, a website save during the run, a failed history insert (rolled back), an existing backup file, and the unchanged default behavior.
  • Production, dry run only, read-only login: runs cleanly. No --write run on production.

Merge Danger

Door: two-way. Nothing changes until someone runs the script with the new option and --write; the backup CSV holds the replaced rows.

Blast Radius: migration. Only this one-off script and its conversion helpers.

Assisted-by: ClaudeCode:claude-opus-5-5

…gain

The conversion skips every subject that already has explicit responsibilities,
so running it again just before the switch would leave the rows of the first
run in place even where the live schedule or status has changed since.

--replace-unedited-since DATE converts those subjects again, unless someone
saved them on the website after DATE. Rows that would not change are left
alone, the replaced rows are first saved to a backup CSV, and everything is
written in one transaction that stops if a subject was saved meanwhile.

Assisted-by: ClaudeCode:claude-opus-5-5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant