-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: academic calendar controllers and routes #81
base: main
Are you sure you want to change the base?
feat: academic calendar controllers and routes #81
Conversation
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.
Good job, but there are some issues I encountered when testing this PR.
database/seeders/academic_calendar_and_holiday_and_day_swap_seeder.ts
Outdated
Show resolved
Hide resolved
app/models/academic_calendar.ts
Outdated
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.
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.
Right, I found the bug, but I have encountered the same problem in buildings controller. I'm gonna fix it also. And I can add libraries controller (this table is connected to buildings), I think that could be useful. One question that bothers me in handleSearchQuery in buildings controller is why when I enter enum type in URL as a param it doesn't work (I mean nothing happens, no filtering)?
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.
opened new issue #82 for the second one, good catch
283dc11
to
ffd5bb6
Compare
ffd5bb6
to
ce1571d
Compare
Updated, fix bugs I encountered, add libraries controller, and I put enum types in controllers in scopes as excluded to ignore filtering by them. |
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.
for (const [i, library] of libraries.entries()) { | ||
await library | ||
.related("regularHours") | ||
.createMany([ | ||
regularHours[0], | ||
regularHours[1], | ||
regularHours[2], | ||
regularHours[3], | ||
regularHours[4], | ||
]); |
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.
uhhhh
for (const [i, library] of libraries.entries()) { | |
await library | |
.related("regularHours") | |
.createMany([ | |
regularHours[0], | |
regularHours[1], | |
regularHours[2], | |
regularHours[3], | |
regularHours[4], | |
]); | |
for (const [i, library] of libraries.entries()) { | |
await library | |
.related("regularHours") | |
.createMany(regularHours); |
await library | ||
.related("specialHours") | ||
.createMany([specialHours[0], specialHours[1], specialHours[2]]); | ||
if (i === 0) { | ||
await library.related("specialHours").create(specialHours[3]); | ||
} | ||
} |
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.
here maybe just split the specialHours
array into objects to be assigned to every library and the ones to be assigned to a specific one only
also it's probably better to just do library[0].related(...
outside of the loop instead of looking for the right library in the loop
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.
@typedModel
is required here to enable searching
protected readonly relations = [ | ||
"buildings", | ||
"buildings.aeds", | ||
"buildings.bicycleShowers", | ||
"buildings.foodSpots", | ||
"buildings.libraries", | ||
]; |
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.
could also add buildings.libraries.{regular,special}Hours
support for filtering by enum values just got merged into main, you should be able to properly define model fields that use enums after rebasing onto main. |
Controllers, routes, and seeder for academic calendars.