-
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
400/add managing agency filter type to capital projects #405
base: main
Are you sure you want to change the base?
400/add managing agency filter type to capital projects #405
Conversation
}: { | ||
boroughId: string; | ||
communityDistrictId: string; | ||
limit: number; | ||
offset: number; | ||
managingAgency: string; |
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.
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.
managingAgency: string; | |
managingAgency: string | null; |
@@ -129,6 +131,9 @@ export class BoroughRepository { | |||
and( | |||
eq(communityDistrict.boroughId, boroughId), | |||
eq(communityDistrict.id, communityDistrictId), | |||
managingAgency |
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.
managingAgency | |
managingAgency !== null |
@@ -71,8 +72,9 @@ export class BoroughService { | |||
communityDistrictId, | |||
limit = 20, | |||
offset = 0, | |||
managingAgency = "", |
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.
managingAgency = "", | |
managingAgency = null, |
@@ -74,6 +74,7 @@ export class CityCouncilDistrictService { | |||
async findCapitalProjectsById({ | |||
limit = 20, | |||
offset = 0, | |||
managingAgency = "", |
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.
Same "null" feedback as community districts
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)