Skip to content
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

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

mateusz-plaska
Copy link
Contributor

Controllers, routes, and seeder for academic calendars.

Copy link
Member

@mini-bomba mini-bomba left a 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.

start/routes.ts Outdated Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

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

The relations defined on these models appear to be non-functional :/

screenshots of API results

image
image

Copy link
Contributor Author

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)?

Copy link
Member

@czaja307 czaja307 Jan 20, 2025

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

@mateusz-plaska mateusz-plaska force-pushed the feat/academic-calendar-controllers-and-routes branch from 283dc11 to ffd5bb6 Compare January 20, 2025 21:34
@mateusz-plaska mateusz-plaska force-pushed the feat/academic-calendar-controllers-and-routes branch from ffd5bb6 to ce1571d Compare January 20, 2025 22:03
@mateusz-plaska
Copy link
Contributor Author

Updated, fix bugs I encountered, add libraries controller, and I put enum types in controllers in scopes as excluded to ignore filtering by them.

Copy link
Member

@mini-bomba mini-bomba left a comment

Choose a reason for hiding this comment

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

Tested the routes (except libraries), relations appear to work - good job

but I did find some minor issues

caption

Comment on lines +161 to +170
for (const [i, library] of libraries.entries()) {
await library
.related("regularHours")
.createMany([
regularHours[0],
regularHours[1],
regularHours[2],
regularHours[3],
regularHours[4],
]);
Copy link
Member

Choose a reason for hiding this comment

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

uhhhh

Suggested change
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);

Comment on lines +172 to +178
await library
.related("specialHours")
.createMany([specialHours[0], specialHours[1], specialHours[2]]);
if (i === 0) {
await library.related("specialHours").create(specialHours[3]);
}
}
Copy link
Member

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

Copy link
Member

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

Comment on lines +7 to +13
protected readonly relations = [
"buildings",
"buildings.aeds",
"buildings.bicycleShowers",
"buildings.foodSpots",
"buildings.libraries",
];
Copy link
Member

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

@mini-bomba
Copy link
Member

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.

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/academic calendar controllers and routes
3 participants