From 8f1bf57a657fbbf3940e52e71f3d5f548ce80ef9 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sun, 4 Dec 2022 18:52:01 +0100 Subject: rename missingstations command to integritycheck --- lib/Travelynx/Command/integritycheck.pm | 44 ++++++++++++++++++++++++++++++++ lib/Travelynx/Command/missingstations.pm | 44 -------------------------------- 2 files changed, 44 insertions(+), 44 deletions(-) create mode 100644 lib/Travelynx/Command/integritycheck.pm delete mode 100644 lib/Travelynx/Command/missingstations.pm (limited to 'lib') diff --git a/lib/Travelynx/Command/integritycheck.pm b/lib/Travelynx/Command/integritycheck.pm new file mode 100644 index 0000000..fc7345a --- /dev/null +++ b/lib/Travelynx/Command/integritycheck.pm @@ -0,0 +1,44 @@ +package Travelynx::Command::integritycheck; + +# Copyright (C) 2022 Daniel Friesel +# +# SPDX-License-Identifier: AGPL-3.0-or-later + +use Mojo::Base 'Mojolicious::Command'; +use List::Util qw(); +use Travel::Status::DE::IRIS::Stations; + +sub run { + my ($self) = @_; + + my %station; + + for my $s ( Travel::Status::DE::IRIS::Stations::get_stations() ) { + $station{ $s->[2] } = 1; + } + + my @journey_stations; + + my $res + = $self->app->pg->db->select( 'journeys', ['checkin_station_id'], {}, + { group_by => ['checkin_station_id'] } ); + for my $j ( $res->hashes->each ) { + push( @journey_stations, $j->{checkin_station_id} ); + } + + $res = $self->app->pg->db->select( 'journeys', ['checkout_station_id'], {}, + { group_by => ['checkout_station_id'] } ); + for my $j ( $res->hashes->each ) { + push( @journey_stations, $j->{checkout_station_id} ); + } + + @journey_stations = List::Util::uniq @journey_stations; + + for my $eva (@journey_stations) { + if ( not $station{$eva} ) { + say $eva; + } + } +} + +1; diff --git a/lib/Travelynx/Command/missingstations.pm b/lib/Travelynx/Command/missingstations.pm deleted file mode 100644 index ab340ce..0000000 --- a/lib/Travelynx/Command/missingstations.pm +++ /dev/null @@ -1,44 +0,0 @@ -package Travelynx::Command::missingstations; - -# Copyright (C) 2022 Daniel Friesel -# -# SPDX-License-Identifier: AGPL-3.0-or-later - -use Mojo::Base 'Mojolicious::Command'; -use List::Util qw(); -use Travel::Status::DE::IRIS::Stations; - -sub run { - my ($self) = @_; - - my %station; - - for my $s ( Travel::Status::DE::IRIS::Stations::get_stations() ) { - $station{ $s->[2] } = 1; - } - - my @journey_stations; - - my $res - = $self->app->pg->db->select( 'journeys', ['checkin_station_id'], {}, - { group_by => ['checkin_station_id'] } ); - for my $j ( $res->hashes->each ) { - push( @journey_stations, $j->{checkin_station_id} ); - } - - $res = $self->app->pg->db->select( 'journeys', ['checkout_station_id'], {}, - { group_by => ['checkout_station_id'] } ); - for my $j ( $res->hashes->each ) { - push( @journey_stations, $j->{checkout_station_id} ); - } - - @journey_stations = List::Util::uniq @journey_stations; - - for my $eva (@journey_stations) { - if ( not $station{$eva} ) { - say $eva; - } - } -} - -1; -- cgit v1.2.3