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: departments controllers #75

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

Conversation

Mikuu-252
Copy link
Member

No description provided.

@Mikuu-252 Mikuu-252 linked an issue Jan 9, 2025 that may be closed by this pull request
@Mikuu-252 Mikuu-252 changed the title Departments controller Feat/departments controllers Jan 9, 2025
@Mikuu-252 Mikuu-252 self-assigned this Jan 9, 2025
app/controllers/departments_links_controller.ts Outdated Show resolved Hide resolved
app/models/department.ts Outdated Show resolved Hide resolved
database/seeders/department_seeder.ts Outdated Show resolved Hide resolved
gradientStart: "red",
gradientStop: "blue",
});
await Department.createMany([
Copy link
Member

Choose a reason for hiding this comment

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

it's nice that you added such realistic data :D

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.

minor mistakes

minor_mistake

app/controllers/departments_controller.ts Outdated Show resolved Hide resolved
app/controllers/fields_of_studies_controller.ts Outdated Show resolved Hide resolved
app/models/department.ts Show resolved Hide resolved
app/models/field_of_study.ts Outdated Show resolved Hide resolved
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.

Nice work, but there are still some comments that weren't addressed.

app/controllers/departments_controller.ts Outdated Show resolved Hide resolved
app/controllers/departments_links_controller.ts Outdated Show resolved Hide resolved
Comment on lines 10 to 15
async index({ request }: HttpContext) {
const { page, limit } = await request.validateUsing(paginationValidator);
const baseQuery = FieldsOfStudy.query().withScopes((scopes) => {
scopes.preloadRelations(request.only(this.relations));
scopes.handleSortQuery(request.input("sort"));
});
Copy link
Member

Choose a reason for hiding this comment

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

The scope for searching is missing.

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.

Final round of changes?

Copy link
Member

Choose a reason for hiding this comment

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

you can now revert the changes mage to this file

Comment on lines 12 to 18
const baseQuery = FieldsOfStudy.query().withScopes((scopes) => {
scopes.handleSearchQuery(
request.only(["id", "name", "createdAt", "updatedAt"]),
);
scopes.preloadRelations(request.only(this.relations));
scopes.handleSortQuery(request.input("sort"));
});
Copy link
Member

@mini-bomba mini-bomba Jan 19, 2025

Choose a reason for hiding this comment

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

why are we excluding so many fields that are potentially useful to filter by?
IMO only the url should not be searchable.

Suggested change
const baseQuery = FieldsOfStudy.query().withScopes((scopes) => {
scopes.handleSearchQuery(
request.only(["id", "name", "createdAt", "updatedAt"]),
);
scopes.preloadRelations(request.only(this.relations));
scopes.handleSortQuery(request.input("sort"));
});
const baseQuery = FieldsOfStudy.query().withScopes((scopes) => {
scopes.handleSearchQuery(request.qs(), "url");
scopes.preloadRelations(request.only(this.relations));
scopes.handleSortQuery(request.input("sort"));
});

Comment on lines 13 to 20
scopes.handleSearchQuery(
request.except([
"logo",
"description",
"gradientStart",
"gradientStop",
]),
);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
scopes.handleSearchQuery(
request.except([
"logo",
"description",
"gradientStart",
"gradientStop",
]),
);
scopes.handleSearchQuery(
request.qs(),
"logo",
"description",
"gradientStart",
"gradientStop",
);

+ prettier cuz i typed this out by hand

@mini-bomba mini-bomba changed the title Feat/departments controllers feat: departments controllers Jan 19, 2025
@czaja307 czaja307 self-requested a review January 27, 2025 09:09
Copy link
Member

@czaja307 czaja307 left a comment

Choose a reason for hiding this comment

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

@Mikuu-252 you have to resolve conflicts

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/departments controller and routes
3 participants