Skip to content

Conversation

@jasutiin
Copy link

@jasutiin jasutiin commented Feb 10, 2026

This PR doesn't handle assigning users to a meal time slot.

The general flow of creating a meal and scanning users in to a meal is as follows:

  • create meal with meal title, start time, end time (instead of a duration), and the admin that scanned the user in
  • later when scanning users in, the admin selects a meal and then scans each person to that meal, adding a meal attendance record attached to the user and that meal

The reason why I am storing end time instead of a duration is because SQL doesn't have a duration type iirc.

I've also created a new client component in the frontend for testing out this functionality. It has checks for scanning in the same user to the same meal, creating a meal with the same title and start time, and creating a meal with an end time that is before the start time. I didn't style the component because I heard we're moving from SCSS to Tailwind because the previous version of HMT used Tailwind and we're trying to preserve the styles from that version.

my idea is to have a qr code for each user. when we create a meal, we
create a meal attendance record for that user at that meal. they can't
scan again. if we allow leftovers for that meal, we would create another
meal called "{meal} leftovers" or whatever so that they can scan in to
that instead. may get a bit annoying to keep having to create meals for
leftovers if we allow them to line up for leftovers again and again.
i changed the addMeal procedure to be public instead of protected for
now because idk how to handle authentication. this is why i am not using
requireRole in the client component as well. also changed startTime and
endTime to string() without changing it to datetime because had issues
with type mismatch.
added a validation check to ensure endTime is after startTime for meals.
also made it so that meals need to have unique titles and start times.
having the same end time is fine because we could set "Breakfast" to be
from 9am to 10am, and then "Breakfast leftovers" from 9:45am to 10am. it
just means all breakfast related things end at 10am.
implemented a scanUserIn public procedure and added a section in my
meals page to scan in a user for testing purposes
.notNull()
.references(() => user.id, { onDelete: "cascade" }),
// checkedInBy is the admin that scanned the user in for the meal
checkedInBy: text("checked_in_by")
Copy link
Contributor

Choose a reason for hiding this comment

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

might not be necessary to store the exact person who scanned in - might be easier to just have this as a boolean. only admins will have access to the scanner anyway


export const meal = createTable("meal", {
id: uuid("id").primaryKey().defaultRandom(),
title: text("title").notNull().unique(), // can be breakfast, lunch, dinner, breakfast leftovers...
Copy link
Contributor

Choose a reason for hiding this comment

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

dont make this unique - if we have two days where an admin wants "Breakfast" it will throw an error trying to insert two Breakfasts into a table

Copy link
Author

@jasutiin jasutiin Feb 10, 2026

Choose a reason for hiding this comment

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

you're right, should we make it a composite key using startTime and title then?

edit: actually on second thought keeping startTime as unique is enough i think. having startTime and title as a composite key allows for the user to create "Lunch" and "Breakfast" on the same startTime.

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.

2 participants