allow caching routing by destination and travel mode; also export all travel methods to csv column

This commit is contained in:
Viktor Barzin 2025-05-20 21:58:08 +00:00
parent f2118c9bc4
commit 10ae25e0d3
No known key found for this signature in database
GPG key ID: 4056458DBDBF8863
5 changed files with 190 additions and 84 deletions

View file

@ -1,4 +1,5 @@
import asyncio
import json
import os
import pathlib
import click
@ -185,11 +186,14 @@ def routing(ctx: click.core.Context, destination_address: str,
raise click.exceptions.MissingParameter(
f'{API_KEY_ENVIRONMENT_VARIABLE} environment variable is not set. '
'Please set it to your API key for the routing service.')
routing_module.calculate_route(
listing_paths,
destination_address,
TravelMode[travel_mode],
)
asyncio.run(
routing_module.calculate_route(
listing_paths,
destination_address,
# destination_address_coordinates,
TravelMode[travel_mode],
))
@cli.command()
@ -223,7 +227,9 @@ def export_csv(ctx: click.core.Context, output_file: str, columns: tuple[str]):
output_file_path = pathlib.Path(output_file)
listing_paths = sorted(list(pathlib.Path(data_dir).glob("*/listing.json")))
listings = Listing.get_all_listings([str(path) for path in listing_paths])
csv_exporter.export_to_csv(listings, output_file_path, list(columns))
asyncio.run(
csv_exporter.export_to_csv(listings, output_file_path,
list(columns)), )
if __name__ == '__main__':