Skip to content

Meal groups#68

Open
NoelVarghese2006 wants to merge 4 commits intomainfrom
meal_groups
Open

Meal groups#68
NoelVarghese2006 wants to merge 4 commits intomainfrom
meal_groups

Conversation

@NoelVarghese2006
Copy link
Copy Markdown
Collaborator

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

    • Added meal_group column to the applications table.
    • Initialized default meal_groups in the settings table.
  • API / Backend

    • Added meal_group support in applications and settings configuration.

    • Implemented store methods for managing meal groups and retrieving distribution statistics.

    • Added superadmin endpoints to:

      • GET/PUT meal groups.
      • View meal group assignment counts.
    • Automated random assignment of meal_group during the check-in scan process.

    • Included meal_group information in scan creation responses.

    • Updated application retrieval queries to include the meal_group field.

- 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)
@NoelVarghese2006 NoelVarghese2006 linked an issue Mar 29, 2026 that may be closed by this pull request
8 tasks
MealGroup: mealGroup,
}

if err := app.jsonResponse(w, http.StatusCreated, response); err != nil {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a return here

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

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.

feat: Meal group assignment for checked-in hackers

2 participants