fix: shift group priorities endpoints#136
Conversation
This fixes the last issues with the shift group priorities endpints. Such as not applying the correct filters and not adding the handler function to the route.
There was a problem hiding this comment.
Pull request overview
Fixes the shift group priorities API so it correctly filters priorities per shift group and properly wires the update handler into the router.
Changes:
- Filter
GetShiftGroupPrioritiesbyshift_group_idinstead of returning all priority records. - Register the
PUT /roster/shift-groups/:id/priorityroute withUpdateShiftGroupPriority.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| internal/roster/service.go | Applies the correct DB filter for shift-group priorities; simplifies return from update method. |
| internal/roster/handler.go | Wires the missing PUT handler; adds a debug-style log on successful update response. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| return | ||
| } | ||
|
|
||
| log.Print(groupPriority) |
There was a problem hiding this comment.
Avoid logging the full groupPriority object on every successful request; this adds noisy logs and may inadvertently expose identifiers in production. If logging is needed, use a structured log at an appropriate level (e.g., debug) with minimal fields, or remove this statement entirely.
| log.Print(groupPriority) |
| func (s *service) GetShiftGroupPriorities(groupID uint) ([]*models.ShiftGroupPriority, error) { | ||
| var priorities []*models.ShiftGroupPriority | ||
| if err := s.db.Find(&priorities).Error; err != nil { | ||
| if err := s.db.Where("shift_group_id = ?", groupID).Find(&priorities).Error; err != nil { |
There was a problem hiding this comment.
GetShiftGroupPriorities previously returned all priorities and now applies a shift_group_id filter. Given the existing service test suite in this package, please add/adjust unit tests to assert this method only returns priorities for the requested groupID (and not priorities from other shift groups).
This fixes the last issues with the shift group priorities endpints. Such as not applying the correct filters and not adding the handler function to the route.
Types of changes