-
Notifications
You must be signed in to change notification settings - Fork 0
HMTV2-21: generate food timeslot #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
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
src/server/db/meal-schema.ts
Outdated
| .notNull() | ||
| .references(() => user.id, { onDelete: "cascade" }), | ||
| // checkedInBy is the admin that scanned the user in for the meal | ||
| checkedInBy: text("checked_in_by") |
There was a problem hiding this comment.
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
src/server/db/meal-schema.ts
Outdated
|
|
||
| export const meal = createTable("meal", { | ||
| id: uuid("id").primaryKey().defaultRandom(), | ||
| title: text("title").notNull().unique(), // can be breakfast, lunch, dinner, breakfast leftovers... |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
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:
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.