working split
Some checks failed
Build and deploy the backend to staging / Build and push image (pull_request) Successful in 1m46s
Run linting on the backend code / Build (pull_request) Successful in 2m31s
Run testing on the backend code / Build (pull_request) Failing after 12m37s
Build and deploy the backend to staging / Deploy to staging (pull_request) Successful in 29s

This commit is contained in:
2025-06-22 14:24:00 +02:00
parent 6921ab57f8
commit e2d3d29956
13 changed files with 369 additions and 103 deletions

View File

@@ -11,7 +11,9 @@ from .structs.preferences import Preferences, Preference
from .structs.linked_landmarks import LinkedLandmarks
from .structs.trip import Trip
from .landmarks.landmarks_manager import LandmarkManager
from .toilets.toilet_routes import router as toilets_router
from .toilets.toilets_route import router as toilets_router
from .optimization.optimization_routes import router as optimization_router
from .landmarks.landmarks_routes import router as landmarks_router
from .optimization.optimizer import Optimizer
from .optimization.refiner import Refiner
from .overpass.overpass import fill_cache
@@ -39,13 +41,17 @@ app = FastAPI(lifespan=lifespan)
app.include_router(toilets_router)
app.include_router(optimization_router)
app.include_router(landmarks_router)
@app.post("/trip/new")
def new_trip(preferences: Preferences,
start: tuple[float, float],
end: tuple[float, float] | None = None,
background_tasks: BackgroundTasks = None) -> Trip:
def new_trip(
preferences: Preferences,
start: tuple[float, float],
end: tuple[float, float] | None = None,
background_tasks: BackgroundTasks = None
) -> Trip:
"""
Main function to call the optimizer.
@@ -226,44 +232,3 @@ def update_trip_time(trip_uuid: str, removed_landmark_uuid: str) -> Trip:
return trip
# TODO: get stuff to do nearby. The idea is to have maybe thhe 3 best things to do within 500m and 2 hidden gems.
@app.post("/landmarks/get-nearby/{lat}/{lon}")
def get_landmarks_nearby(lat: float, lon: float) -> list[Landmark] :
# preferences = {"sightseeing": {"type": "sightseeing", "score": 0},
# "nature": {"type": "nature", "score": 0},
# "shopping": {"type": "shopping", "score": 5},
# "max_time_minute": 30,
# "detour_tolerance_minute": 0},
# Find the landmarks around the location
_, landmarks_around = manager.generate_landmarks_list(
center_coordinates = (lat, lon),
preferences = Preferences(
sightseeing = Preference(
type='sightseeing',
score=5
),
shopping = Preference(
type='shopping',
score=2
),
nature = Preference(
type='nature',
score=5
),
max_time_minute=30,
detour_tolerance_minute=0),
allow_clusters=False
)
if len(landmarks_around) == 0 :
raise HTTPException(status_code=500, detail="No landmarks were found.")
# select 5 landmarks from there
if len(landmarks_around) > 6 :
landmarks_around = landmarks_around[:2] + random.sample(landmarks_around[3:], 2)
logger.info('Suggested landmarks :\n\t' + '\n\t'.join(f'{landmark}' for landmark in landmarks_around))
return landmarks_around