frontend groundwork
Some checks failed
Build and release APK / Build APK (pull_request) Has been cancelled
Build and push docker image / Build (pull_request) Successful in 1m33s

This commit is contained in:
2024-08-01 14:39:15 +02:00
parent 07dde5ab58
commit 86bcec6b29
16 changed files with 417 additions and 168 deletions

View File

@@ -1,6 +1,6 @@
from pydantic import BaseModel, Field
from pymemcache.client.base import Client
from .landmark import Landmark
from .linked_landmarks import LinkedLandmarks
import uuid
@@ -11,7 +11,7 @@ class Trip(BaseModel):
@classmethod
def from_linked_landmarks(self, landmarks: LinkedLandmarks, cache_client) -> "Trip":
def from_linked_landmarks(self, landmarks: LinkedLandmarks, cache_client: Client) -> "Trip":
"""
Initialize a new Trip object and ensure it is stored in the cache.
"""
@@ -22,7 +22,9 @@ class Trip(BaseModel):
# Store the trip in the cache
cache_client.set(f"trip_{trip.uuid}", trip)
for landmark in landmarks:
cache_client.set(f"landmark_{landmark.uuid}", landmark)
cache_client.set_many({f"landmark_{landmark.uuid}": landmark for landmark in landmarks}, expire=3600)
# is equivalent to:
# for landmark in landmarks:
# cache_client.set(f"landmark_{landmark.uuid}", landmark, expire=3600)
return trip