Unverified Commit 0f44f869 authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

integritycheck: add sub-commands

parent fcd78440
Loading
Loading
Loading
Loading
+126 −108
Original line number Diff line number Diff line
@@ -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;