You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(planning): guarded tool to restore shift-1 ids damaged by the planning read - #910
The plugin's planning read used to run Start1Id /= 5 + 1 (integer division by 6) and save the row. That was fixed in plugin #1732. Before the fix it damaged shift-1 ids on about 3,300 one-minute rows. On a few five-minute shifts that cross midnight it also overwrote the stop stamp. This PR adds a guarded tool that puts the original values back from a manifest.
ShiftIdRepair.ApplyAsync runs inside one transaction through the execution strategy and locks the manifest rows with FOR UPDATE. For each row it checks that:
the row still exists for the same worker and date;
its Version and both ids still match the manifest;
the row is not reconciled, and its date is not locked by DayLock.
If all checks pass, it sets the ids, plus the stamps when the manifest gives them, and saves through PnBase.Update, which writes a version row. Hours and flex are never touched. Rows that are Changed, Missing or Locked are reported and do not block the others. A lost commit acknowledgement is detected the same way as in the flex repair tool.
tools/ShiftIdRepair is a console app that is not in the .sln; CI builds it.
Dry run is the default. --apply requires --confirm-database.
It works in chunks of 200 lines and refuses an --out folder that is not empty.
It writes and fsyncs the before-image before any report row. A reversed manifest undoes a run.
With --apply it stops at the first chunk that throws.
ShiftIdRepairCsv reads and writes the manifest and the before-image using invariant culture. The Date column accepts a bare date.
The manifests are built offline from PlanRegistrationVersions: each id gets the value it had just before the divide-by-6, checked against the row's stamps. They hold row ids and numbers only and stay out of the repository.
Tests
ShiftIdRepairTests (DbTestFixture) covers:
repair, including the version row;
a dry run that writes nothing;
Changed, Missing and Locked;
hours left untouched;
a rejected line that does not block the others;
undo with a reversed manifest.
ShiftIdRepairCsvTests covers the header, column count, duplicate ids, the da-DK culture, a bare Date, and the round trips.
…anning read
A planning-read workaround (removed in the plugin) divided Start1Id/Stop1Id
by six and, on five-minute rows crossing midnight, overwrote the stop
stamp. ShiftIdRepair applies a manifest of the original values: per row it
checks the row still has the version and ids seen when the manifest was
built and is not on a reconciled day, then sets the ids (and stamps when
given) through PnBase.Update so each change gets a version row. Dry run by
default; --apply requires --confirm-database; the before-image is written
to disk first and a reversed manifest undoes the repair.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VDsVLaH7SqGi1bFk8nAtP1
…ng the day lock
Locking only the manifest rows let a reconciliation of a later day of the
same worker commit between the reconciled-boundary read and our commit.
Reconciliation updates that worker's PlanRegistrations rows, so locking all
of the chunk's workers' rows first makes it wait for our commit and keeps
the boundary valid until then.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VDsVLaH7SqGi1bFk8nAtP1
Repeated value flags are rejected, but --apply bypasses that duplicate check, so --apply --apply ... is accepted despite the documented rule that repeated flags are invocation errors. Check apply before setting it and return the same duplicate-flag error used for value flags.
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
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.
Summary
The plugin's planning read used to run
Start1Id /= 5 + 1(integer division by 6) and save the row. That was fixed in plugin #1732. Before the fix it damaged shift-1 ids on about 3,300 one-minute rows. On a few five-minute shifts that cross midnight it also overwrote the stop stamp. This PR adds a guarded tool that puts the original values back from a manifest.ShiftIdRepair.ApplyAsyncruns inside one transaction through the execution strategy and locks the manifest rows withFOR UPDATE. For each row it checks that:Versionand both ids still match the manifest;DayLock.If all checks pass, it sets the ids, plus the stamps when the manifest gives them, and saves through
PnBase.Update, which writes a version row. Hours and flex are never touched. Rows that areChanged,MissingorLockedare reported and do not block the others. A lost commit acknowledgement is detected the same way as in the flex repair tool.tools/ShiftIdRepairis a console app that is not in the.sln; CI builds it.--applyrequires--confirm-database.--outfolder that is not empty.--applyit stops at the first chunk that throws.ShiftIdRepairCsvreads and writes the manifest and the before-image using invariant culture. TheDatecolumn accepts a bare date.The manifests are built offline from
PlanRegistrationVersions: each id gets the value it had just before the divide-by-6, checked against the row's stamps. They hold row ids and numbers only and stay out of the repository.Tests
ShiftIdRepairTests(DbTestFixture) covers:Changed,MissingandLocked;ShiftIdRepairCsvTestscovers the header, column count, duplicate ids, the da-DK culture, a bareDate, and the round trips.🤖 Generated with Claude Code
https://claude.ai/code/session_01VDsVLaH7SqGi1bFk8nAtP1