Drop old services before updating GTFS data
This commit is contained in:
parent
6ef1df2757
commit
ee5eb13a01
|
@ -56,8 +56,6 @@ class Command(BaseCommand):
|
||||||
|
|
||||||
self.stdout.write("Updating database...")
|
self.stdout.write("Updating database...")
|
||||||
|
|
||||||
all_trips = []
|
|
||||||
|
|
||||||
for transport_type, feed_url in self.GTFS_FEEDS.items():
|
for transport_type, feed_url in self.GTFS_FEEDS.items():
|
||||||
self.stdout.write(f"Downloading {transport_type} GTFS feed...")
|
self.stdout.write(f"Downloading {transport_type} GTFS feed...")
|
||||||
with ZipFile(BytesIO(requests.get(feed_url).content)) as zipfile:
|
with ZipFile(BytesIO(requests.get(feed_url).content)) as zipfile:
|
||||||
|
@ -161,6 +159,7 @@ class Command(BaseCommand):
|
||||||
unique_fields=['id'])
|
unique_fields=['id'])
|
||||||
routes.clear()
|
routes.clear()
|
||||||
|
|
||||||
|
Calendar.objects.filter(transport_type=transport_type).delete()
|
||||||
calendar_ids = []
|
calendar_ids = []
|
||||||
if "calendar.txt" in zipfile.namelist():
|
if "calendar.txt" in zipfile.namelist():
|
||||||
calendars = []
|
calendars = []
|
||||||
|
@ -299,8 +298,6 @@ class Command(BaseCommand):
|
||||||
unique_fields=['id'])
|
unique_fields=['id'])
|
||||||
trips.clear()
|
trips.clear()
|
||||||
|
|
||||||
all_trips.extend(trips)
|
|
||||||
|
|
||||||
stop_times = []
|
stop_times = []
|
||||||
for stop_time_dict in csv.DictReader(read_file("stop_times.txt")):
|
for stop_time_dict in csv.DictReader(read_file("stop_times.txt")):
|
||||||
stop_time_dict: dict
|
stop_time_dict: dict
|
||||||
|
|
Loading…
Reference in New Issue