Skip to content

Commit 9a5c559

Browse files
author
Indraneel Purohit
committedMar 13, 2024·
Update main.py
1 parent 1fa23c3 commit 9a5c559

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed
 

‎app/backend/main.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ async def get_route_summary(msa_id: str, route: str):
8383
SELECT
8484
agencies_serviced
8585
FROM public.stop_features
86-
WHERE '{route}' = any(public.stop_features.routes_serviced)
86+
WHERE '{route}' = any(string_to_array(public.stop_features.routes_serviced_str, ','))
8787
AND public.stop_features.city = '{msa_id}'
8888
"""
8989
cursor.execute(agency_query)
@@ -96,7 +96,7 @@ async def get_route_summary(msa_id: str, route: str):
9696
SELECT
9797
{col}, count({col})
9898
FROM public.stop_features
99-
WHERE '{route}' = any(routes_serviced)
99+
WHERE '{route}' = any(string_to_array(public.stop_features.routes_serviced_str, ','))
100100
AND city = '{msa_id}'
101101
GROUP BY {col}
102102
"""
@@ -123,14 +123,14 @@ async def stops_on_route(cities: Union[List[str], None] = Query(default=None), r
123123
routes_serviced
124124
FROM public.stop_features
125125
WHERE
126-
'{routes[0]}'::text = ANY(routes_serviced)
126+
'{routes[0]}'::text = ANY(string_to_array(public.stop_features.routes_serviced_str, ','))
127127
AND
128128
'{cities[0]}' = city
129129
"""
130130

131131
for i in range(1, len(cities)):
132132
stops_query += f"""
133-
OR ('{routes[i]}'::text = ANY(routes_serviced) AND '{cities[i]}' = city)
133+
OR ('{routes[i]}'::text = ANY(string_to_array(public.stop_features.routes_serviced_str, ',')) AND '{cities[i]}' = city)
134134
"""
135135

136136
cursor.execute(stops_query)
@@ -149,7 +149,7 @@ async def get_all_available_routes():
149149

150150
routes_query = f"""
151151
SELECT
152-
DISTINCT unnest(public.stop_features.routes_serviced) AS route,
152+
DISTINCT unnest(string_to_array(public.stop_features.routes_serviced_str, ',')) AS route,
153153
public.stop_features.route_type,
154154
public.cities.msa_name,
155155
public.stop_features.city as msa_id

0 commit comments

Comments
 (0)
Please sign in to comment.