Wip on changing flow with the minion

This commit is contained in:
Finn 2019-07-08 16:41:59 +01:00
parent c7ef724a46
commit ff19c81074
3 changed files with 49 additions and 8 deletions

View file

@ -0,0 +1,34 @@
package Pear::LocalLoop::Plugin::Minion::Job::csv_supplier_import;
use Mojo::Base 'Pear::LocalLoop::Plugin::Minion::Job';
use Devel::Dwarn;
sub run {
my ( $self, $rows ) = @_;
foreach my $row ( @{$rows} ) {
$self->_row_to_result($row);
}
}
sub _row_to_result {
my ( $self, $row ) = @_;
# Dwarn $row->{supplier_id};
my $addr2 = $row->{post_town};
my $address = ( defined $addr2 ? ( $row->{"address line 2"} . ' ' . $addr2) : $row->{"address line 2"} );
$self->external_result->find_or_create_related('organisations', {
external_id => $row->{supplier_id},
organisation => {
name => $row->{name},
street_name => $row->{"address line 1"},
town => $address,
postcode => $row->{post_code},
country => $row->{country_code},
entity => { type => 'organisation' },
}
});
$self->app->log->debug('Imported the CSV fully!');
}
1;