Skip to content

Commit

Permalink
Add coalesce in opa_only query to accomondate unit parcel addresses (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander-M-Waldman authored Feb 17, 2024
1 parent e69b3a4 commit d354d46
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions ais/api/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -769,3 +769,7 @@ def test_inherited_tags_from_aggregate_parent_are_lowest(client):
response = client.get('/search/901 N PENN ST UNIT F1102')
data = json.loads(response.get_data().decode())
assert data['features'][0]['properties']['bin'] == '1032992'

def test_unit_address_parcel_property_opa_only(client):
response = client.get('/search/1650 N 5TH ST UNIT A?opa_only')
assert_status(response, 200)
4 changes: 3 additions & 1 deletion ais/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1027,7 +1027,7 @@ def exclude_non_opa(self, should_exclude=True):
# it's base's OPA account number. In the case where the
# address does not have a base, the base num will be None.
(AddressSummary.unit_type != '') &
(AddressSummary.opa_account_num == BaseAddressSummary.opa_account_num)
(AddressSummary.opa_account_num == func.coalesce(BaseAddressSummary.opa_account_num, ''))
)) \
.order_by(AddressSummary.opa_address, desc(AddressSummary.street_address == AddressSummary.opa_address)) \
.distinct(AddressSummary.opa_address)
Expand All @@ -1036,6 +1036,7 @@ def exclude_non_opa(self, should_exclude=True):
else:
return self


def get_all_parcel_geocode_locations(self, srid=DEFAULT_API_SRID, request=None):

geocode_xy_join = self \
Expand All @@ -1051,6 +1052,7 @@ def get_all_parcel_geocode_locations(self, srid=DEFAULT_API_SRID, request=None):
# return result of query without flag (set i=1 so all geocode_location flags are ignored)
return self.get_address_geoms(request=request, i=1)


def get_parcel_geocode_location(self, parcel_geocode_location=None, srid=DEFAULT_API_SRID, request=None):
if self.first():
# If request arg parcel_geocode_location is included (and if on_street arg is not),
Expand Down

0 comments on commit d354d46

Please sign in to comment.