From 1444574d2676aa39da730b92c3d6cb4e3d33d88b Mon Sep 17 00:00:00 2001 From: Finn Date: Tue, 9 Jul 2019 17:55:50 +0100 Subject: [PATCH] Properly catch errors loading minions --- lib/Pear/LocalLoop/Import/LCCCsv/Transactions.pm | 11 +++++++---- lib/Pear/LocalLoop/Plugin/Minion.pm | 8 +++++--- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/Pear/LocalLoop/Import/LCCCsv/Transactions.pm b/lib/Pear/LocalLoop/Import/LCCCsv/Transactions.pm index a143af4..eb906f7 100644 --- a/lib/Pear/LocalLoop/Import/LCCCsv/Transactions.pm +++ b/lib/Pear/LocalLoop/Import/LCCCsv/Transactions.pm @@ -19,7 +19,7 @@ sub import_csv { my ($self) = @_; my $rows = $self->csv_data; - my $lcc_org = $self->schema->resultset('Organisation')->find({ name => "Lancashire County Council" }); + # my $lcc_org = $self->schema->resultset('Organisation')->find({ name => "Lancashire County Council" }); foreach my $row ( @{$rows} ) { $self->_row_to_result($row); } @@ -44,6 +44,8 @@ sub _row_to_result { my $paid_date = ( $row->{paid_date} ? $date_formatter->parse_datetime($row->{paid_date}) : DateTime->today ); + #my $distance = $self->get_distance_from_coords( $organisation, $lcc_org ); + # TODO negative values are sometimes present $self->external_result->find_or_create_related('transactions', { external_id => $row->{transaction_id}, @@ -53,10 +55,11 @@ sub _row_to_result { purchase_time => $paid_date, value => $row->{net_amount}, meta => { - gross_value => $row->{gross_amount}, - sales_tax_value => $row->{"vat amount"}, - net_value => $row->{net_amount}, + gross_value => $row->{gross_amount} * 100000, + sales_tax_value => $row->{"vat amount"} * 100000, + net_value => $row->{net_amount} * 100000, }, + # distance => $distance, } }); } diff --git a/lib/Pear/LocalLoop/Plugin/Minion.pm b/lib/Pear/LocalLoop/Plugin/Minion.pm index 54a592b..cfe4442 100644 --- a/lib/Pear/LocalLoop/Plugin/Minion.pm +++ b/lib/Pear/LocalLoop/Plugin/Minion.pm @@ -15,11 +15,13 @@ sub register { my $job_namespace = __PACKAGE__ . '::Job'; my @modules = find_modules $job_namespace; for my $package ( @modules ) { - my ( $job ) = $package =~ /${job_namespace}::(.*)$/; + my ( $job_name ) = $package =~ /${job_namespace}::(.*)$/; $app->log->debug( $package ); - load_class $package; + if (my $e = load_class $package) { + die ref $e ? "Exception: $e" : "$package not found"; + } $app->minion->add_task( - $job => sub { + $job_name => sub { my ( $job, @args ) = @_; my $job_runner = $package->new( job => $job,