forked from bloom-housing/bloom
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Contribute Detroit filters to Bloom (bloom-housing#1884)
* Contribute Detroit filters to Bloom * Contribute Detroit filters to Bloom * update changelog * fix malformed query * rename ami filter * Don't include nulls in senior housing filter * fix: cleanup after upstream merge Co-authored-by: Sean Albert <smabert@gmail.com>
- Loading branch information
1 parent
9a1b51c
commit 7086b8e
Showing
12 changed files
with
521 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,44 @@ | ||
// Using a record lets us enforce that all types are handled in addFilter | ||
import { ListingFilterKeys } from "../../.." | ||
|
||
export const filterTypeToFieldMap: Record<keyof typeof ListingFilterKeys, string> = { | ||
/** | ||
* Fields for the Availability and AMI filters are determined based on the value | ||
* of the filter or by checking multiple columns. Since we can't specify a single | ||
* field the filters correspond to, we remove them from the filterTypeToFieldMap. | ||
*/ | ||
type keysWithMappedField = Exclude< | ||
keyof typeof ListingFilterKeys, | ||
"minAmiPercentage" | "availability" | ||
> | ||
|
||
export const filterTypeToFieldMap: Record<keysWithMappedField, string> = { | ||
status: "listings.status", | ||
name: "listings.name", | ||
neighborhood: "property.neighborhood", | ||
bedrooms: "unitTypeRef.num_bedrooms", | ||
zipcode: "buildingAddress.zipCode", | ||
leasingAgents: "leasingAgents.id", | ||
seniorHousing: "reservedCommunityType.name", | ||
// This is the inverse of the explanation for maxRent below. | ||
minRent: "unitsSummary.monthly_rent_max", | ||
/** | ||
* The maxRent filter uses the monthly_rent_min field to avoid missing units | ||
* in the unitsSummary's rent range. For example, if there's a unitsSummary with | ||
* monthly_rent_min of $300 and monthly_rent_max of $800, we could have a | ||
* real unit with rent $500, which would look like: | ||
* | ||
* $300 ---------------- $500 ------ $600 ----------- $800 | ||
* ^ ^ ^ ^ | ||
* ^ ^ ^ ^ | ||
* | | | unitsSummary.monthly_rent_max | ||
* | | maxRent filter value | ||
* | actual unit's rent | ||
* unitsSummary.monthly_rent_min | ||
* | ||
* If a user sets the maxRent filter to $600 we should show this potential unit. | ||
* To make sure we show this potential unit in results, we want to search for | ||
* listings with a monthly_rent_min that's <= $600. If we used the | ||
* monthly_rent_max field, we'd miss it. | ||
*/ | ||
maxRent: "unitsSummary.monthly_rent_min", | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.