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

400/add managing agency filter type to capital projects #405

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

Conversation

pratishta
Copy link
Contributor

@pratishta pratishta commented Jan 22, 2025

Closes #400

I found some inconsistencies in how we write CD and CCD so I fixed those in here as well (specifying a return type in the service, and adding limit and offset query params to the borough mocks)

@pratishta pratishta marked this pull request as ready for review January 22, 2025 18:24
@pratishta pratishta requested a review from a team January 22, 2025 18:24
}: {
boroughId: string;
communityDistrictId: string;
limit: number;
offset: number;
managingAgency: string;
Copy link
Member

@TangoYankee TangoYankee Jan 24, 2025

Choose a reason for hiding this comment

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

You're already checking for truthiness underneath, so the code itself is good. But for type housekeeping, I think managingAgency could also be undefined because it's optional

I see in the service that we're setting "managingAgency" to a default value of an "empty string" and then doing a truthy check in the sql query. Truthy checks are considered a "gotcha". They don't always behave predictably. Instead, if we're going to give it a default value, it should be null. Then, we explicitly check for null values.

Suggested change
managingAgency: string;
managingAgency: string | null;

@@ -129,6 +131,9 @@ export class BoroughRepository {
and(
eq(communityDistrict.boroughId, boroughId),
eq(communityDistrict.id, communityDistrictId),
managingAgency
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
managingAgency
managingAgency !== null

@@ -71,8 +72,9 @@ export class BoroughService {
communityDistrictId,
limit = 20,
offset = 0,
managingAgency = "",
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
managingAgency = "",
managingAgency = null,

@@ -74,6 +74,7 @@ export class CityCouncilDistrictService {
async findCapitalProjectsById({
limit = 20,
offset = 0,
managingAgency = "",
Copy link
Member

Choose a reason for hiding this comment

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

Same "null" feedback as community districts

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.

Add managing agency filter to capital projects endpoints
2 participants