Added properly working imports with minions and status
This commit is contained in:
parent
22e6001362
commit
d0506c2a95
7 changed files with 49 additions and 59 deletions
|
@ -1,34 +1,15 @@
|
|||
package Pear::LocalLoop::Plugin::Minion::Job::csv_supplier_import;
|
||||
use Mojo::Base 'Pear::LocalLoop::Plugin::Minion::Job';
|
||||
use Devel::Dwarn;
|
||||
|
||||
use Pear::LocalLoop::Import::LCCCsv::Suppliers;
|
||||
|
||||
sub run {
|
||||
my ( $self, $rows ) = @_;
|
||||
my ( $self, $filename ) = @_;
|
||||
|
||||
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!');
|
||||
my $csv_import = Pear::LocalLoop::Import::LCCCsv::Suppliers->new(
|
||||
csv_file => $filename,
|
||||
schema => $self->app->schema
|
||||
)->import_csv;
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
package Pear::LocalLoop::Plugin::Minion::Job::csv_transaction_import;
|
||||
use Mojo::Base 'Pear::LocalLoop::Plugin::Minion::Job';
|
||||
|
||||
use Pear::LocalLoop::Import::LCCCsv::Transactions;
|
||||
|
||||
sub run {
|
||||
my ( $self, $filename ) = @_;
|
||||
|
||||
my $csv_import = Pear::LocalLoop::Import::LCCCsv::Transactions->new(
|
||||
csv_file => $filename,
|
||||
schema => $self->app->schema
|
||||
)->import_csv;
|
||||
}
|
||||
|
||||
1;
|
Reference in a new issue