Skip to content

Commit

Permalink
attributions.txt fix
Browse files Browse the repository at this point in the history
Signed-off-by: Clemens Vasters <[email protected]>
  • Loading branch information
clemensv committed Oct 14, 2024
1 parent d5cd119 commit 450ae03
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions gtfs/gtfs_rt_bridge/src/gtfs_rt_bridge/gtfs_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from typing import Any, Dict, List, Tuple
from datetime import datetime, timedelta, timezone
from tempfile import TemporaryDirectory
import uuid
from zipfile import ZipFile
from enum import Enum
import dataclasses
Expand Down Expand Up @@ -303,7 +304,7 @@ def map_areas(rows: List[Dict[str, Any]]) -> List[Areas]:
def map_attributions(rows: List[Dict[str, Any]]) -> List[Attributions]:
"""Maps the rows from the attributions.txt file to a list of Attributions objects"""
return [Attributions(
attributionId=row.get("attribution_id"),
attributionId=row.get("attribution_id", row.get("trip_id", uuid.uuid4().hex)),
agencyId=row.get("agency_id"),
routeId=row.get("route_id"),
tripId=row.get("trip_id"),
Expand Down Expand Up @@ -815,7 +816,7 @@ async def fetch_and_process_schedule(agency_id: str, reference_producer_client:
entities = map_attributions(file_contents)
logger.info("Processing %s attributions entities", len(entities))
for entity in entities:
await reference_producer_client.send_general_transit_feed_static_attributions(agency_url, (entity.agencyId if entity.agencyId else agency_id)+"/"+entity.attributionId+"/"+entity.routeId+"/"+entity.tripId, entity, flush_producer=False)
await reference_producer_client.send_general_transit_feed_static_attributions(agency_url, (entity.agencyId if entity.agencyId else agency_id)+"/"+entity.attributionId+"/"+(entity.routeId if entity.routeId else "any")+"/"+entity.tripId, entity, flush_producer=False)
send_count += 1
if send_count % 100 == 0:
reference_producer_client.producer.flush()
Expand Down

0 comments on commit 450ae03

Please sign in to comment.