Properly catch errors loading minions

This commit is contained in:
Finn 2019-07-09 17:55:50 +01:00
parent 9c79e50eba
commit 1444574d26
No known key found for this signature in database
GPG key ID: 7455B4B17685B598
2 changed files with 12 additions and 7 deletions

View file

@ -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,
}
});
}

View file

@ -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,