diff --git a/sncfgtfs/management/commands/update_sncf_gtfs.py b/sncfgtfs/management/commands/update_sncf_gtfs.py index e801344..1e3d4fb 100644 --- a/sncfgtfs/management/commands/update_sncf_gtfs.py +++ b/sncfgtfs/management/commands/update_sncf_gtfs.py @@ -188,7 +188,7 @@ class Command(BaseCommand): unique_fields=['id']) calendars.clear() if calendars and not dry_run: - Calendar.objects.bulk_create(calendars, update_conflicts=True, + Calendar.objects.bulk_create(calendars.values(), update_conflicts=True, update_fields=['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday', 'start_date', 'end_date', 'transport_type'], @@ -402,3 +402,31 @@ class Command(BaseCommand): version=feed_info_dict.get('feed_version', 1), ) ) + + # print(len(all_trips)) + # print(Trip.objects.count()) + # existing_trips = set(Trip.objects.filter( + # id__in=[trip.id for trip in all_trips]).values_list('id', flat=True)) + # new_trips = [trip.id for trip in all_trips if trip.id not in existing_trips] + # removed_trips = Trip.objects.exclude(id__in=[trip.id for trip in all_trips]) + # + # yes_ok, yes_not_ok, no_ok, no_not_ok = 0, 0, 0, 0 + # today = datetime.now().date() + # for removed_trip in removed_trips: + # trip_id = removed_trip.id.split(':')[0] + # service = removed_trip.service + # active_trip = service.dates.filter(date__gte=today, exception_type=1).exists() + # service_today = service.dates.count() == 1 and service.dates.filter(date="2024-02-05").exists() + # if trip_id != "IDFM": + # if any(tid.startswith(trip_id) for tid in new_trips): + # if active_trip: + # yes_ok += 1 + # else: + # yes_not_ok += 1 + # else: + # if active_trip: + # print("NOT FOUND WHILE VALID SERVICE", trip_id) + # no_not_ok += 1 + # else: + # no_ok += 1 + # print(yes_ok, yes_not_ok, no_ok, no_not_ok)