integritycheck: add sub-commands

This commit is contained in:
Birte Kristina Friesel 2024-09-01 11:38:44 +02:00
parent fcd78440a5
commit 0f44f8695d
No known key found for this signature in database
GPG key ID: 19E6E524EBB177BA

View file

@ -9,10 +9,13 @@ use List::Util qw();
use Travel::Status::DE::IRIS::Stations;
sub run {
my ($self) = @_;
my ( $self, $mode ) = @_;
my $found = 0;
my $db = $self->app->pg->db;
if ( $mode eq 'all' or $mode eq 'unknown-evas' ) {
my %notified;
my $res1 = $db->query(
qq{
select checkin_station_id
@ -21,7 +24,6 @@ sub run {
where stations.eva is null;
}
);
my $res2 = $db->query(
qq{
select checkout_station_id
@ -31,7 +33,6 @@ sub run {
}
);
my %notified;
while ( my $row = $res1->hash ) {
my $eva = $row->{checkin_station_id};
if ( not $found ) {
@ -63,6 +64,7 @@ sub run {
$notified{$eva} = 1;
}
}
}
if ($found) {
say '------------8<----------';
@ -70,9 +72,12 @@ sub run {
$found = 0;
}
my $rename = $self->app->renamed_station;
if ( $mode eq 'all' or $mode eq 'unknown-route-entries' ) {
my %notified;
my $rename = $self->app->renamed_station;
my $res = $db->select( 'journeys', [ 'route', 'edited' ] )->expand;
while ( my $j = $res->hash ) {
if ( $j->{edited} & 0x0010 ) {
next;
@ -91,8 +96,10 @@ sub run {
if ( not $found ) {
say
'Journeys in the travelynx database contain the following unknown route entries.';
say 'Note that this check ignores manual route entries.';
say 'All reports refer to routes obtained via HAFAS/IRIS.';
say
'Note that this check ignores manual route entries.';
say
'All reports refer to routes obtained via HAFAS/IRIS.';
say '------------8<----------';
say 'Travel::Status::DE::IRIS v'
. $Travel::Status::DE::IRIS::Stations::VERSION;
@ -103,6 +110,7 @@ sub run {
}
}
}
}
if ($found) {
say '------------8<----------';
@ -110,11 +118,14 @@ sub run {
$found = 0;
}
$res = $db->select(
if ( $mode eq 'all' or $mode eq 'checkout-eva-vs-route-eva' ) {
my $res = $db->select(
'journeys_str',
[ 'journey_id', 'sched_arr_ts', 'route', 'arr_name', 'arr_eva' ],
{ backend_id => 0 }
)->expand;
journey: while ( my $j = $res->hash ) {
my $found_in_route;
my $found_arr;
@ -152,4 +163,11 @@ sub run {
}
}
if ($found) {
say '------------8<----------';
say '';
$found = 0;
}
}
1;