Drop transfers before populating new ones

This commit is contained in:
Emmy D'Anello 2024-05-27 23:49:12 +02:00
parent 0d622302ac
commit a4a8cd9e9f
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85
1 changed files with 2 additions and 0 deletions

View File

@ -9,6 +9,7 @@ from zoneinfo import ZoneInfo
import requests
from django.core.management import BaseCommand
from django.db import transaction
from django.db.models import Q
from tqdm import tqdm
from trainvel.gtfs.models import Agency, Calendar, CalendarDate, FeedInfo, GTFSFeed, Route, Stop, StopTime, \
@ -368,6 +369,7 @@ class Command(BaseCommand):
stop_times.clear()
if os.path.exists(os.path.join(zip_dir, "transfers.txt")):
Transfer.objects.filter(Q(from_stop__gtfs_feed_id=gtfs_code) | Q(to_stop__gtfs_feed_id=gtfs_code)).delete()
transfers = []
for transfer_dict in read_csv("transfers.txt"):
transfer_dict: dict