From bcdb8d2bf21245b15b1c06fc38b6ae634ad3566a Mon Sep 17 00:00:00 2001 From: Adam Vajda Date: Sat, 9 Dec 2023 03:16:17 +0100 Subject: [PATCH] Fix backend find_competitors --- common/find_competitors.py | 2 +- routers/ws.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/common/find_competitors.py b/common/find_competitors.py index 2146ca1..cc36806 100644 --- a/common/find_competitors.py +++ b/common/find_competitors.py @@ -12,7 +12,7 @@ def get_k_nearest(data, lat, lon, k=3): data_copy['distance'] = data_copy.apply(lambda x: get_distance(lat, lon, x['lat'], x['lon']), axis=1) return data_copy.sort_values(by=['distance']).head(k) -def find_competitors(business_type, lng, lat): +def find_competitors(business_type, lat, lng): dataset = pd.read_csv(os.path.join(os.path.dirname(__file__), 'pois.csv')) business_data = dataset[dataset['property_type'] == business_type] k_nearest = get_k_nearest(business_data, lat, lng) diff --git a/routers/ws.py b/routers/ws.py index 7215663..f055284 100644 --- a/routers/ws.py +++ b/routers/ws.py @@ -19,7 +19,7 @@ async def websocket_endpoint(websocket: WebSocket): try: await websocket.accept() - await websocket.send_json({"progress": 0}) + await websocket.send_json({"progress": random.randint(1, 5)}) data = await websocket.receive_json() prompt = data["prompt"] @@ -74,7 +74,7 @@ async def websocket_endpoint(websocket: WebSocket): await asyncio.sleep(1) - await websocket.send_json(find_competitors.find_competitors(response_json["business_type"], lng, lat)) + await websocket.send_json(find_competitors.find_competitors(response_json["business_type"], lat, lng)) await websocket.send_json({"progress": random.randint(50, 60)})