Skip to content

Commit

Permalink
GCP utils integration update
Browse files Browse the repository at this point in the history
  • Loading branch information
grisxa committed Mar 17, 2024
1 parent 64b6260 commit 69eb257
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 18 deletions.
20 changes: 3 additions & 17 deletions strava_watcher/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
from pytz import utc
from requests import HTTPError

from brevet_top_gcp_utils import create_document, firestore_to_track_point
from brevet_top_gcp_utils import (create_document, firestore_to_track_point,
get_checkpoints)
from brevet_top_strava import (ActivityError, ActivityNotFound,
AthleteNotFound, auth_token,
build_checkpoint_list, get_activity,
Expand Down Expand Up @@ -137,7 +138,7 @@ def strava_compare(athlete_id: int, activity_id: int, secret: dict):
]

# prepare a list of control points (check-in / check-out) necessary to visit
checkpoints, ids = build_checkpoint_list(get_checkpoints(brevet_dict["uid"]))
checkpoints, ids = build_checkpoint_list(get_checkpoints(brevet_dict["uid"], db=db_client))
# logging.debug(f"Checkpoints {checkpoints} / {ids}")

# start searching
Expand Down Expand Up @@ -192,21 +193,6 @@ def search_brevets(start_date: datetime) -> List[dict]:
]


def get_checkpoints(brevet_uid: str) -> List[dict]:
checkpoints: list = [
cp.to_dict()
for cp in db_client.document(f"brevets/{brevet_uid}")
.collection("checkpoints")
.get()
]
checkpoints.sort(key=lambda x: x.get("distance", 0))
return [
{**cp, "coordinates": firestore_to_track_point(cp)}
for cp in checkpoints
if cp.get("uid")
]


def create_rider_barcode(rider_uid: str, code: str, time: datetime) -> str:
return create_document(
f"riders/{rider_uid}/barcodes",
Expand Down
2 changes: 1 addition & 1 deletion strava_watcher/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ python_dateutil==2.8.2
pytz==2021.3
rdp==0.8
numpy>=1.21.5
brevet-top-gcp-utils==0.1.1
brevet-top-gcp-utils==0.1.4
brevet-top-strava==0.1.1

0 comments on commit 69eb257

Please sign in to comment.