From ee5eb13a01629514caa132dd0bfb3daaaade5e94 Mon Sep 17 00:00:00 2001 From: Emmy D'Anello Date: Sat, 10 Feb 2024 18:30:36 +0100 Subject: [PATCH] Drop old services before updating GTFS data --- sncfgtfs/management/commands/update_sncf_gtfs.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/sncfgtfs/management/commands/update_sncf_gtfs.py b/sncfgtfs/management/commands/update_sncf_gtfs.py index ed71cc9..6078b55 100644 --- a/sncfgtfs/management/commands/update_sncf_gtfs.py +++ b/sncfgtfs/management/commands/update_sncf_gtfs.py @@ -56,8 +56,6 @@ class Command(BaseCommand): self.stdout.write("Updating database...") - all_trips = [] - for transport_type, feed_url in self.GTFS_FEEDS.items(): self.stdout.write(f"Downloading {transport_type} GTFS feed...") with ZipFile(BytesIO(requests.get(feed_url).content)) as zipfile: @@ -161,6 +159,7 @@ class Command(BaseCommand): unique_fields=['id']) routes.clear() + Calendar.objects.filter(transport_type=transport_type).delete() calendar_ids = [] if "calendar.txt" in zipfile.namelist(): calendars = [] @@ -299,8 +298,6 @@ class Command(BaseCommand): unique_fields=['id']) trips.clear() - all_trips.extend(trips) - stop_times = [] for stop_time_dict in csv.DictReader(read_file("stop_times.txt")): stop_time_dict: dict