Fix transfers

This commit is contained in:
Emmy D'Anello 2024-08-12 20:49:27 +02:00
parent bd8d39fc1e
commit bc23d63c43
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85
2 changed files with 93 additions and 1 deletions

View File

@ -377,11 +377,30 @@ class Command(BaseCommand):
to_stop_id = transfer_dict['to_stop_id'] to_stop_id = transfer_dict['to_stop_id']
from_stop_id = f"{gtfs_code}-{from_stop_id}" from_stop_id = f"{gtfs_code}-{from_stop_id}"
to_stop_id = f"{gtfs_code}-{to_stop_id}" to_stop_id = f"{gtfs_code}-{to_stop_id}"
from_route_id = transfer_dict.get('from_route_id', None)
from_route_id = f"{gtfs_code}-{from_route_id}" if from_route_id else None
to_route_id = transfer_dict.get('to_route_id', None)
to_route_id = f"{gtfs_code}-{to_route_id}" if to_route_id else None
from_trip_id = transfer_dict.get('from_trip_id', None)
from_trip_id = f"{gtfs_code}-{from_trip_id}" if from_trip_id else None
to_trip_id = transfer_dict.get('to_trip_id', None)
to_trip_id = f"{gtfs_code}-{to_trip_id}" if to_trip_id else None
transfer_id = f"{gtfs_code}-{transfer_dict['from_stop_id']}-{transfer_dict['to_stop_id']}"
if from_route_id and to_route_id:
transfer_id += f"-{from_route_id}-{to_route_id}"
if from_trip_id and to_trip_id:
transfer_id += f"-{from_trip_id}-{to_trip_id}"
transfer_id += f"-{transfer_dict['transfer_type']}"
transfer = Transfer( transfer = Transfer(
id=f"{gtfs_code}-{transfer_dict['from_stop_id']}-{transfer_dict['to_stop_id']}", id=transfer_id,
from_stop_id=from_stop_id, from_stop_id=from_stop_id,
to_stop_id=to_stop_id, to_stop_id=to_stop_id,
from_route_id=from_route_id,
to_route_id=to_route_id,
from_trip_id=from_trip_id,
to_trip_id=to_trip_id,
transfer_type=transfer_dict['transfer_type'], transfer_type=transfer_dict['transfer_type'],
min_transfer_time=transfer_dict.get('min_transfer_time', 0) or 0, min_transfer_time=transfer_dict.get('min_transfer_time', 0) or 0,
) )

View File

@ -0,0 +1,73 @@
# Generated by Django 5.0.6 on 2024-08-12 18:33
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("gtfs", "0004_trip_long_distance_trip_route_name_trip_route_type_and_more"),
]
operations = [
migrations.AddField(
model_name="transfer",
name="from_route",
field=models.ForeignKey(
blank=True,
default=None,
null=True,
on_delete=django.db.models.deletion.CASCADE,
related_name="transfers_from",
to="gtfs.route",
verbose_name="From route",
),
),
migrations.AddField(
model_name="transfer",
name="from_trip",
field=models.ForeignKey(
blank=True,
default=None,
null=True,
on_delete=django.db.models.deletion.CASCADE,
related_name="transfers_from",
to="gtfs.trip",
verbose_name="From trip",
),
),
migrations.AddField(
model_name="transfer",
name="to_route",
field=models.ForeignKey(
blank=True,
default=None,
null=True,
on_delete=django.db.models.deletion.CASCADE,
related_name="transfers_to",
to="gtfs.route",
verbose_name="To route",
),
),
migrations.AddField(
model_name="transfer",
name="to_trip",
field=models.ForeignKey(
blank=True,
default=None,
null=True,
on_delete=django.db.models.deletion.CASCADE,
related_name="transfers_to",
to="gtfs.trip",
verbose_name="To trip",
),
),
migrations.AlterField(
model_name="transfer",
name="min_transfer_time",
field=models.IntegerField(
blank=True, default=None, verbose_name="Minimum transfer time"
),
),
]