Repository navigation
Reject unsupported RequiredStaff values instead of silently storing 1 - #4
Merged
Merged
Conversation
The model staffs each shift with exactly one employee: ShiftEntity has a single EmployeeId and no RequiredStaff column, schedule generation assigns one employee per open shift, coverage counts shifts with an employee, and simulation suggests one employee. POST /api/shifts still accepted any RequiredStaff and silently persisted 1, and the simulation UI let users request more staff than could ever be assigned. - Add Shift.SupportedRequiredStaff (1) and IsSupportedRequiredStaff as the single source of truth; use it in ShiftRepository - Return 400 for RequiredStaff != 1 on POST /api/shifts, /api/schedule/simulate and /api/load-analysis; omitted values default to 1 - Replace the simulation staffing input with a fixed note - Document the staffing model and add unit and integration tests - Run CI for pull requests to any base branch (same trigger, permissions and concurrency block as the CI PR) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Problem
ShiftRepositorydoes not persistRequiredStaff(ShiftEntityhas no such column), and every shift is loaded withRequiredStaff = 1.POST /api/shiftsacceptedrequiredStaff: 3, echoed3back, and stored 1. The simulation UI had a free "Krævet bemanding" field: asking for 3 people still returned one suggested employee and "can be covered".Analysis of the domain model
The system only supports one employee per shift:
ShiftEntity.EmployeeIdis a single value; there is noRequiredStaffcolumnScheduleGeneratorServicepicks one matching employee per open shift (AssignToEmployee(id))ScheduleOverviewServicecounts a shift as assigned whenEmployeeId != nullScheduleSimulationServicereturns oneSuggestedEmployeeIdShift.RequiredStaff,IsFullyStaffed()andMissingStaffCount()only work on the in-memoryAssignedEmployeeslist, which is never persisted.Supporting several employees per shift would need a new join table and migration, multi-assignment in the generator, partial coverage in the overview, multi-candidate simulation, and frontend changes across every view. That is a product decision, not a bug fix. The smallest correct solution is to make the API honest about the actual model.
Solution
Shift.SupportedRequiredStaff = 1andShift.IsSupportedRequiredStaff(int). These are the single source of truth, documented on the class.ShiftRepositoryuses the constant instead of a magic1.POST /api/shifts,POST /api/schedule/simulateandPOST /api/load-analysisreturn400 { "error": "RequiredStaff must be 1. Each shift is staffed by one employee; create one shift per required employee." }for any value other than 1. An omittedrequiredStaffdefaults to 1. Before, the shift and load-analysis endpoints read an omitted value as 0.requiredStaff: 1.pull_requesttrigger,permissionsandconcurrencyblock are copied verbatim from Add frontend lint and build to CI and fix lint errors #1. That lets this stacked PR get CI, and it merges cleanly with Add frontend lint and build to CI and fix lint errors #1 (verified).The scheduling logic is unchanged. The in-memory
IsFullyStaffed/MissingStaffCounthelpers and their domain tests are kept.Test results
New integration tests:
POST /api/shiftswith 0/2/3 → 400 and nothing persistedrequiredStaff: 1round-trips through SQLiteFull local integration of #1 + #2 + #3 + this PR:
dotnet test63 + 29 passed, frontendlintclean,npm test8 passed,buildOK.Limitations
requiredStaff > 1. Those values were never honoured, so no stored data changes.🤖 Generated with Claude Code