Conversation
- Add meal_group column to applications table - Initialize default meal_groups in settings table
- Add meal_group column to applications and default configuration in settings - Implement store methods for meal group management and distribution stats - Add superadmin endpoints to GET/PUT meal groups and view assignment counts - Automate random meal group assignment during the check-in scan process - Include meal_group information in the scan creation response - Update application retrieval queries to include the meal_group field
BREAKING CHANGE (eslint-plugin-boundaries)
| MealGroup: mealGroup, | ||
| } | ||
|
|
||
| if err := app.jsonResponse(w, http.StatusCreated, response); err != nil { |
There was a problem hiding this comment.
it looks like the frontend wasn't updated to take in this new response format?
| } | ||
|
|
||
| if err := app.jsonResponse(w, http.StatusCreated, response); err != nil { | ||
| app.internalServerError(w, r, err) |
There was a problem hiding this comment.
actually its technically not needed, but include it for clarity
|
|
||
| if err := app.jsonResponse(w, http.StatusCreated, scan); err != nil { | ||
| if found.Category == store.ScanCategoryCheckIn { | ||
| app.assignMealGroup(r.Context(), req.UserID) |
There was a problem hiding this comment.
I think in the future we should separate meal scans and check in scans to different functions, might be helpful for implementing other things based on whether a person is checked in or not.
| } | ||
| } | ||
|
|
||
| type UpdateMealGroupsPayload struct { |
There was a problem hiding this comment.
update meal groups requires at least one string, but we have a specific check for len(groups) == 0 in assignMealGroup. Do we want a case where there are no meal groups?
| } | ||
|
|
||
| if err := app.jsonResponse(w, http.StatusOK, MealGroupsResponse{Groups: groups}); err != nil { | ||
| app.internalServerError(w, r, err) |
There was a problem hiding this comment.
add return for clarity after internalServerError
| -- Add default meal groups to settings | ||
| -- Assumes a settings table with 'key' and 'value' (JSONB) columns | ||
| INSERT INTO settings (key, value) | ||
| VALUES ('meal_groups', '["A", "B", "C", "D"]'::jsonb) |
There was a problem hiding this comment.
should this be something in task seed instead? I think migrations are supposed to be the base config, if we put in A,B,C,D in the migrate up, its not exactly a base configuration
| } | ||
|
|
||
| // SetMealGroups updates the available meal group names | ||
| func (s *SettingsStore) SetMealGroups(ctx context.Context, groups []string) error { |
There was a problem hiding this comment.
I guess there's a guarantee that groups has at least one value, but if we want to include the case where there are no meal groups then you'd need to cover that case here. (I think we should be able to have no meal groups, will be easier for non-tech admins to set up)
Summary
This PR introduces meal group support to enable staggered meal times for hackers. It includes database updates, API changes, and automated assignment during check-in.
Changes
Database
meal_groupcolumn to theapplicationstable.meal_groupsin thesettingstable.API / Backend
Added
meal_groupsupport in applications and settings configuration.Implemented store methods for managing meal groups and retrieving distribution statistics.
Added superadmin endpoints to:
Automated random assignment of
meal_groupduring the check-in scan process.Included
meal_groupinformation in scan creation responses.Updated application retrieval queries to include the
meal_groupfield.