Skip to content

Commit

Permalink
Sync to typesense only if new stations are present
Browse files Browse the repository at this point in the history
  • Loading branch information
gsarrco committed Sep 28, 2023
1 parent 3a598e4 commit b10c26a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions MuoVErsi/sources/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,14 +285,19 @@ def sync_stations_typesense(self, stations: list[Station]):

stations_collection.documents.delete({'filter_by': f'source:{self.name}'})

stations_collection.documents.import_([{
stations_to_sync = [{
'id': station.id,
'name': station.name,
'location': [station.lat, station.lon],
'ids': station.ids,
'source': station.source,
'times_count': station.times_count
} for station in stations])
} for station in stations]

if not stations_to_sync:
return

stations_collection.documents.import_(stations_to_sync)

def get_stop_from_ref(self, ref) -> Station | None:
stmt = select(Station) \
Expand Down

0 comments on commit b10c26a

Please sign in to comment.