projects
/
kivitendo-erp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
PartImport: check_existing etwas optimiert, spart bei Testimports gut 40% Zeit.
[kivitendo-erp.git]
/
SL
/
Controller
/
CsvImport
/
Base.pm
diff --git
a/SL/Controller/CsvImport/Base.pm
b/SL/Controller/CsvImport/Base.pm
index
67ca191
..
185c7ad
100644
(file)
--- a/
SL/Controller/CsvImport/Base.pm
+++ b/
SL/Controller/CsvImport/Base.pm
@@
-15,14
+15,16
@@
use parent qw(Rose::Object);
use Rose::Object::MakeMethods::Generic
(
use Rose::Object::MakeMethods::Generic
(
- scalar => [ qw(controller file csv save_with_cascade) ],
+ scalar => [ qw(controller file csv
test_run
save_with_cascade) ],
'scalar --get_set_init' => [ qw(profile displayable_columns existing_objects class manager_class cvar_columns all_cvar_configs all_languages payment_terms_by all_vc vc_by) ],
);
sub run {
'scalar --get_set_init' => [ qw(profile displayable_columns existing_objects class manager_class cvar_columns all_cvar_configs all_languages payment_terms_by all_vc vc_by) ],
);
sub run {
- my ($self) = @_;
+ my ($self, %params) = @_;
+
+ $self->test_run($params{test_run});
- $self->controller->track_progress(0);
+ $self->controller->track_progress(
phase => 'parsing csv', progress =>
0);
my $profile = $self->profile;
$self->csv(SL::Helper::Csv->new(file => $self->file->file_name,
my $profile = $self->profile;
$self->csv(SL::Helper::Csv->new(file => $self->file->file_name,
@@
-35,14
+37,14
@@
sub run {
map { ( $_ => $self->controller->profile->get($_) ) } qw(sep_char escape_char quote_char),
));
map { ( $_ => $self->controller->profile->get($_) ) } qw(sep_char escape_char quote_char),
));
- $self->controller->track_progress(
1
);
+ $self->controller->track_progress(
progress => 10
);
my $old_numberformat = $::myconfig{numberformat};
$::myconfig{numberformat} = $self->controller->profile->get('numberformat');
$self->csv->parse;
my $old_numberformat = $::myconfig{numberformat};
$::myconfig{numberformat} = $self->controller->profile->get('numberformat');
$self->csv->parse;
- $self->controller->track_progress(
3
);
+ $self->controller->track_progress(
progress => 50
);
$self->controller->errors([ $self->csv->errors ]) if $self->csv->errors;
$self->controller->errors([ $self->csv->errors ]) if $self->csv->errors;
@@
-55,21
+57,17
@@
sub run {
$self->controller->raw_data_headers({ used => { }, headers => [ ] });
$self->controller->info_headers({ used => { }, headers => [ ] });
$self->controller->raw_data_headers({ used => { }, headers => [ ] });
$self->controller->info_headers({ used => { }, headers => [ ] });
- $::lxdebug->dump(0, "self", $self->controller->info_headers);
- $::lxdebug->dump(0, "self", $self->controller->headers);
- $::lxdebug->dump(0, "self", $self->controller->raw_data_headers);
-
my @objects = $self->csv->get_objects;
my @objects = $self->csv->get_objects;
- $self->controller->track_progress(
4
);
+ $self->controller->track_progress(
progress => 70
);
my @raw_data = @{ $self->csv->get_data };
my @raw_data = @{ $self->csv->get_data };
- $self->controller->track_progress(
4.5
);
+ $self->controller->track_progress(
progress => 80
);
$self->controller->data([ pairwise { { object => $a, raw_data => $b, errors => [], information => [], info_data => {} } } @objects, @raw_data ]);
$self->controller->data([ pairwise { { object => $a, raw_data => $b, errors => [], information => [], info_data => {} } } @objects, @raw_data ]);
- $self->controller->track_progress(
5
);
+ $self->controller->track_progress(
progress => 90
);
$self->check_objects;
if ( $self->controller->profile->get('duplicates', 'no_check') ne 'no_check' ) {
$self->check_objects;
if ( $self->controller->profile->get('duplicates', 'no_check') ne 'no_check' ) {
@@
-78,7
+76,7
@@
sub run {
}
$self->fix_field_lengths;
}
$self->fix_field_lengths;
- $self->controller->track_progress(
99
);
+ $self->controller->track_progress(
progress => 100
);
$::myconfig{numberformat} = $old_numberformat;
}
$::myconfig{numberformat} = $old_numberformat;
}
@@
-239,7
+237,7
@@
sub init_profile {
}
}
}
}
-
$self->profile(\%profile)
;
+
\%profile
;
}
sub add_displayable_columns {
}
sub add_displayable_columns {
@@
-387,6
+385,8
@@
sub save_objects {
return unless $data->[0];
return unless $data->[0]{object};
return unless $data->[0];
return unless $data->[0]{object};
+ $self->controller->track_progress(phase => 'saving objects', progress => 0); # scale from 45..95%;
+
my $dbh = $data->[0]{object}->db;
$dbh->begin_work;
my $dbh = $data->[0]{object}->db;
$dbh->begin_work;
@@
-404,7
+404,7
@@
sub save_objects {
} continue {
if ($entry_index % 100 == 0) {
$dbh->commit;
} continue {
if ($entry_index % 100 == 0) {
$dbh->commit;
- $self->controller->track_progress(
45 + $entry_index/scalar(@$data) * 5
0); # scale from 45..95%;
+ $self->controller->track_progress(
progress => $entry_index/scalar(@$data) * 10
0); # scale from 45..95%;
$dbh->begin_work;
}
}
$dbh->begin_work;
}
}