Revision 98f37c10
Von Sven Schöling vor fast 12 Jahren hinzugefügt
SL/Controller/CsvImport.pm | ||
---|---|---|
89 | 89 |
|
90 | 90 |
$self->profile($profile); |
91 | 91 |
|
92 |
if ($data->{progress} < 100) { |
|
92 |
if ($data->{errors} and my $first_error = $data->{errors}->[0]) { |
|
93 |
flash('error', $::locale->text('There was an error parsing the csv file: #1 in line #2.', $first_error->[2], $first_error->[0])); |
|
94 |
} |
|
95 |
|
|
96 |
if (!$data->{progress}{finished}) { |
|
93 | 97 |
$self->render('csv_import/_deferred_results', { no_layout => 1 }); |
94 | 98 |
} else { |
95 | 99 |
$self->action_report(report_id => $data->{report_id}, no_layout => 1); |
... | ... | |
206 | 210 |
file => $self->csv_file_name, |
207 | 211 |
profile => $self->profile, |
208 | 212 |
type => $self->profile->type, |
213 |
test => $params{test}, |
|
209 | 214 |
)->save; |
210 | 215 |
|
211 | 216 |
SL::System::TaskServer->start_if_not_running; |
... | ... | |
234 | 239 |
|
235 | 240 |
$worker->run; |
236 | 241 |
|
242 |
return if $self->errors; |
|
243 |
|
|
237 | 244 |
$self->num_imported(0); |
238 | 245 |
$worker->save_objects if !$params{test}; |
239 | 246 |
|
... | ... | |
313 | 320 |
sub save_report { |
314 | 321 |
my ($self, $report_id) = @_; |
315 | 322 |
|
323 |
$self->track_progress(phase => 'building report', progress => 0); |
|
324 |
|
|
316 | 325 |
my $clone_profile = $self->profile->clone_and_reset_deep; |
317 | 326 |
$clone_profile->save; # weird bug. if this isn't saved before adding it to the report, it will default back to the last profile. |
318 | 327 |
|
... | ... | |
349 | 358 |
my $o2 = $o1 + @methods; |
350 | 359 |
|
351 | 360 |
for my $row (0 .. $#{ $self->data }) { |
361 |
$self->track_progress(progress => $row / @{ $self->data } * 100) if $row % 100 == 0; |
|
352 | 362 |
my $data_row = $self->{data}[$row]; |
353 | 363 |
|
354 | 364 |
$sth->execute($report->id, $_, $row + 1, $data_row->{info_data}{ $info_methods[$_] }) for 0 .. $#info_methods; |
... | ... | |
393 | 403 |
} |
394 | 404 |
|
395 | 405 |
sub track_progress { |
396 |
my ($self, $progress) = @_;
|
|
406 |
my ($self, %params) = @_;
|
|
397 | 407 |
|
398 | 408 |
for my $tracker ($self->progress_tracker) { |
399 |
$tracker->track_progress($progress);
|
|
409 |
$tracker->track_progress(%params);
|
|
400 | 410 |
} |
401 | 411 |
} |
402 | 412 |
|
Auch abrufbar als: Unified diff
Progress genauer anzeigen