From 9e31110dcb953917cd175867baf0237997a5bc93 Mon Sep 17 00:00:00 2001 From: Jose Contreras Date: Thu, 30 Apr 2020 14:35:40 -0700 Subject: [PATCH 1/3] Change sql statement to return place_name. --- app/controllers/bgroup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/bgroup.py b/app/controllers/bgroup.py index 249d41a..b466a40 100644 --- a/app/controllers/bgroup.py +++ b/app/controllers/bgroup.py @@ -69,11 +69,11 @@ class BuildingBGroupController(RestController): SELECT id, building_bgroup.building_id, - string_agg(street_address || ' ' || zipcode, ', ') AS address_list + place_name AS address_list FROM groups.building_bgroup JOIN vw_building_address ON (building_bgroup.building_id = vw_building_address.building_id) WHERE bgroup_id = {} - GROUP BY building_bgroup.building_id, id + GROUP BY building_bgroup.building_id, id, place_name '''.format(bgroup_id) # Query for buildings that are not in the materialized view aka Baltimore right now -- GitLab From 9501982d4cb0aa35cd389fff74c5834b1bebd75a Mon Sep 17 00:00:00 2001 From: Jose Contreras Date: Thu, 30 Apr 2020 14:39:17 -0700 Subject: [PATCH 2/3] Adjust indentation levels for second query. --- app/controllers/bgroup.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/app/controllers/bgroup.py b/app/controllers/bgroup.py index b466a40..19a7874 100644 --- a/app/controllers/bgroup.py +++ b/app/controllers/bgroup.py @@ -78,16 +78,16 @@ class BuildingBGroupController(RestController): # Query for buildings that are not in the materialized view aka Baltimore right now alt_query = ''' - SELECT - bg.id as id, - bg.building_id, - string_agg(concat(a.house_number, ' ', a.street_name) || ' ' || zipcode, ', ') AS address_list - FROM groups.building_bgroup bg - JOIN public.building b on bg.building_id = b.id - join public.building_address ba on b.id = ba.building_id - join public.address a on ba.address_id = a.id - WHERE bgroup_id = {} - GROUP BY bg.building_id, bg.id; + SELECT + bg.id as id, + bg.building_id, + string_agg(concat(a.house_number, ' ', a.street_name) || ' ' || zipcode, ', ') AS address_list + FROM groups.building_bgroup bg + JOIN public.building b on bg.building_id = b.id + join public.building_address ba on b.id = ba.building_id + join public.address a on ba.address_id = a.id + WHERE bgroup_id = {} + GROUP BY bg.building_id, bg.id; '''.format(bgroup_id) results = self.db.session.execute(query).fetchall() -- GitLab From f5456e229eaf6322d87f36438ab5fbe957aa6141 Mon Sep 17 00:00:00 2001 From: Jose Contreras Date: Thu, 30 Apr 2020 14:40:39 -0700 Subject: [PATCH 3/3] Add todo note to remove query. --- app/controllers/bgroup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/bgroup.py b/app/controllers/bgroup.py index 19a7874..fe014ab 100644 --- a/app/controllers/bgroup.py +++ b/app/controllers/bgroup.py @@ -76,7 +76,7 @@ class BuildingBGroupController(RestController): GROUP BY building_bgroup.building_id, id, place_name '''.format(bgroup_id) - # Query for buildings that are not in the materialized view aka Baltimore right now + # Query for buildings that are not in the materialized view aka Baltimore right now TODO: remove this query alt_query = ''' SELECT bg.id as id, -- GitLab