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

246 Implement findCommunityDistrictsByBoroughId endpoint #303

Merged

Conversation

horatiorosa
Copy link
Contributor

@horatiorosa horatiorosa commented Jun 4, 2024

Description

implement find community districts by borough id endpoint
- cd by id controller, module, repository, service
- added notNull constraints to community districts schema + migration
- added unit and e2e tests

Tickets

Closes #246

@horatiorosa horatiorosa self-assigned this Jun 4, 2024
@horatiorosa horatiorosa marked this pull request as draft June 4, 2024 16:13
@horatiorosa horatiorosa force-pushed the 246/Implement-findCommunityDistrictsByBoroughId-endpoint-2 branch 2 times, most recently from a8a69e6 to 104e86b Compare June 7, 2024 13:13
@horatiorosa horatiorosa linked an issue Jun 7, 2024 that may be closed by this pull request
3 tasks
@horatiorosa horatiorosa marked this pull request as ready for review June 7, 2024 13:20
@horatiorosa horatiorosa requested a review from a team June 7, 2024 13:20
@horatiorosa horatiorosa force-pushed the 246/Implement-findCommunityDistrictsByBoroughId-endpoint-2 branch 3 times, most recently from bdf0c19 to 727b99a Compare June 7, 2024 13:44
Copy link
Contributor

@pratishta pratishta left a comment

Choose a reason for hiding this comment

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

We should remove 🚧 from /boroughs/{boroughId}/community-districts: in the openapi documentation since this PR implements it

src/borough/borough.service.ts Outdated Show resolved Hide resolved
@horatiorosa horatiorosa force-pushed the 246/Implement-findCommunityDistrictsByBoroughId-endpoint-2 branch 2 times, most recently from 16f5e5b to f746ec9 Compare June 7, 2024 14:41
Copy link
Contributor

@pratishta pratishta left a comment

Choose a reason for hiding this comment

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

If you could include 'Related to' or 'Closes' with the ticket number so the merge automatically handles the ticket, that'd be great. :) Otherwise LGTM

@pratishta pratishta self-requested a review June 7, 2024 14:45
Copy link
Contributor

@pratishta pratishta left a comment

Choose a reason for hiding this comment

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

Wait, wrong documentation... you want to remove the emoji from "summary: 🚧 Find community districts within a borough"

 implement find community districts by borough id endpoint
 -  cd by id controller, module, repository, service
 - added notNull contraints to community districts schema + migration
 - added unit and e2e tests
@horatiorosa horatiorosa force-pushed the 246/Implement-findCommunityDistrictsByBoroughId-endpoint-2 branch from f746ec9 to 0c501f7 Compare June 7, 2024 14:50
@horatiorosa
Copy link
Contributor Author

🤦🏽‍♂️ @pratishta

@horatiorosa horatiorosa requested a review from pratishta June 7, 2024 14:51
@horatiorosa horatiorosa merged commit e2af46a into main Jun 7, 2024
3 checks passed
@horatiorosa horatiorosa deleted the 246/Implement-findCommunityDistrictsByBoroughId-endpoint-2 branch June 7, 2024 14:55
@@ -20,6 +22,6 @@ export const communityDistrict = pgTable(
);

export const communityDistrictEntitySchema = z.object({
boroughId: z.string().length(1),
id: z.string().length(2),
boroughId: z.string().length(1).regex(new RegExp("[1-9]")),
Copy link
Member

Choose a reason for hiding this comment

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

We updated this schema. It now includes 0 in the range:

pattern: '^([0-9])$'

.expect(400);
expect(response.body.error).toBe(HttpName.BAD_REQUEST);
});

Copy link
Member

Choose a reason for hiding this comment

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

We should tests for 404s when requests are made to non-existent boroughs.

).not.toThrow();
});

it("service should throw a resource error when requesting with a missing id", async () => {
Copy link
Member

Choose a reason for hiding this comment

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

An empty string is different from an id that is not in the database. Empty strings are invalid request parameters. In practical terms, it would never make it to the service. The controller should throw an error before it gets to the service.

To test for a missing id, we want to look at what zod-mock lists and then pick an id that's not in that generated list. This is why we leverage seeding in our mocks- to ensure the generated data is always the same and never accidentally includes the id we designated as "missing"

Copy link
Contributor Author

@horatiorosa horatiorosa Jun 7, 2024

Choose a reason for hiding this comment

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

I misunderstood, thanks for explaining. I was thinking missing id as in not there and not as in missing from the db.

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.

Implement findCommunityDistrictsByBoroughId endpoint
4 participants