Skip to content

Commit

Permalink
dumpstops: provide backend name and type rather than just opaque IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
derf committed Aug 7, 2024
1 parent 1bb348a commit 7e9f6bd
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
22 changes: 22 additions & 0 deletions lib/Travelynx/Command/database.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2600,6 +2600,28 @@ qq{select distinct checkout_station_id from in_transit where backend_id = 0;}
say
'If the migration fails due to a deadlock, re-run it after stopping all background workers';
},

# v55 -> v56
# include backend data in dumpstops command
sub {
my ($db) = @_;
$db->query(
qq{
create view stations_str as
select stations.name as name,
eva, lat, lon,
backends.name as backend,
iris as is_iris,
hafas as is_hafas,
efa as is_efa,
ris as is_ris
from stations
left join backends
on source = backends.id;
update schema_version set version = 56;
}
);
},
);

sub sync_stations {
Expand Down
5 changes: 3 additions & 2 deletions lib/Travelynx/Command/dumpstops.pm
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ sub run {
or die("open($filename): $!\n");

my $csv = Text::CSV->new( { eol => "\r\n" } );
$csv->combine(qw(name eva lat lon source archived));
$csv->combine(qw(name eva lat lon backend is_iris is_hafas));
print $fh $csv->string;

my $iter = $self->app->stations->get_db_iterator;
while ( my $row = $iter->hash ) {
$csv->combine( @{$row}{qw{name eva lat lon source archived}} );
$csv->combine(
@{$row}{qw{name eva lat lon backend is_iris is_hafas}} );
print $fh $csv->string;
}
close($fh);
Expand Down
2 changes: 1 addition & 1 deletion lib/Travelynx/Model/Stations.pm
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ sub add_meta {
sub get_db_iterator {
my ($self) = @_;

return $self->{pg}->db->select( 'stations', '*' );
return $self->{pg}->db->select( 'stations_str', '*' );
}

sub get_meta {
Expand Down

0 comments on commit 7e9f6bd

Please sign in to comment.