Skip to content

Commit

Permalink
Fix backend find_competitors
Browse files Browse the repository at this point in the history
  • Loading branch information
vjdad4m committed Dec 9, 2023
1 parent 3f0aaf7 commit bcdb8d2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion common/find_competitors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions routers/ws.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down Expand Up @@ -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)})

Expand Down

0 comments on commit bcdb8d2

Please sign in to comment.