From 7d9b7d90cdad2979f5f89125512bae07664e62ee Mon Sep 17 00:00:00 2001 From: Emmy D'Anello Date: Sun, 12 May 2024 12:14:48 +0200 Subject: [PATCH] Fix StopTime ID --- trainvel/gtfs/management/commands/update_trainvel_gtfs.py | 5 ++--- trainvel/gtfs/management/commands/update_trainvel_gtfs_rt.py | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/trainvel/gtfs/management/commands/update_trainvel_gtfs.py b/trainvel/gtfs/management/commands/update_trainvel_gtfs.py index 880e8ff..bbb0cdb 100644 --- a/trainvel/gtfs/management/commands/update_trainvel_gtfs.py +++ b/trainvel/gtfs/management/commands/update_trainvel_gtfs.py @@ -19,7 +19,7 @@ class Command(BaseCommand): def add_arguments(self, parser): parser.add_argument('--debug', '-d', action='store_true', help="Activate debug mode") - parser.add_argument('--bulk_size', '-b', type=int, default=10000, help="Number of objects to create in bulk.") + parser.add_argument('--bulk_size', '-b', type=int, default=2000, help="Number of objects to create in bulk.") parser.add_argument('--dry-run', action='store_true', help="Do not update the database, only print what would be done.") parser.add_argument('--force', '-f', action='store_true', help="Force the update of the database.") @@ -343,8 +343,7 @@ class Command(BaseCommand): # pickup_type = PickupType.NONE st = StopTime( - id=f"{gtfs_code}-{stop_time_dict['trip_id']}-{stop_time_dict['stop_id']}" - f"-{stop_time_dict['departure_time']}", + id=f"{gtfs_code}-{stop_time_dict['trip_id']}-{stop_time_dict['stop_sequence']}", trip_id=trip_id, arrival_time=timedelta(seconds=arr_time), departure_time=timedelta(seconds=dep_time), diff --git a/trainvel/gtfs/management/commands/update_trainvel_gtfs_rt.py b/trainvel/gtfs/management/commands/update_trainvel_gtfs_rt.py index a50d9ce..7a997fd 100644 --- a/trainvel/gtfs/management/commands/update_trainvel_gtfs_rt.py +++ b/trainvel/gtfs/management/commands/update_trainvel_gtfs_rt.py @@ -191,7 +191,7 @@ class Command(BaseCommand): and stop_sequence < len(trip_update.stop_time_update) - 1 else PickupType.NONE StopTime.objects.update_or_create( - id=f"{trip_id}-{stop_time_update.stop_id}", + id=f"{gtfs_code}-{trip_id}-{stop_time_update.stop_sequence}", trip_id=trip_id, defaults={ "stop_id": stop_id,