|
Lines 49-55
sub job_type {
Link Here
|
| 49 |
|
49 |
|
| 50 |
Koha::BackgroundJobs->find($id)->process( |
50 |
Koha::BackgroundJobs->find($id)->process( |
| 51 |
{ |
51 |
{ |
| 52 |
record_ids => \@itemnumbers, |
52 |
item_ids => \@itemnumbers, |
| 53 |
deleted_biblios => 0|1, |
53 |
deleted_biblios => 0|1, |
| 54 |
} |
54 |
} |
| 55 |
); |
55 |
); |
|
Lines 85-95
sub process {
Link Here
|
| 85 |
$self->started_on(dt_from_string)->progress($job_progress) |
85 |
$self->started_on(dt_from_string)->progress($job_progress) |
| 86 |
->status('started')->store; |
86 |
->status('started')->store; |
| 87 |
|
87 |
|
| 88 |
my @record_ids = @{ $args->{record_ids} }; |
88 |
my @item_ids = @{ $args->{item_ids} }; |
| 89 |
my $delete_biblios = $args->{delete_biblios}; |
89 |
my $delete_biblios = $args->{delete_biblios}; |
| 90 |
|
90 |
|
| 91 |
my $report = { |
91 |
my $report = { |
| 92 |
total_records => scalar @record_ids, |
92 |
total_records => scalar @item_ids, |
| 93 |
total_success => 0, |
93 |
total_success => 0, |
| 94 |
}; |
94 |
}; |
| 95 |
my @messages; |
95 |
my @messages; |
|
Lines 102-112
sub process {
Link Here
|
| 102 |
$schema->txn_do( |
102 |
$schema->txn_do( |
| 103 |
sub { |
103 |
sub { |
| 104 |
my (@biblionumbers); |
104 |
my (@biblionumbers); |
| 105 |
for my $record_id ( sort { $a <=> $b } @record_ids ) { |
105 |
for my $item_id ( sort { $a <=> $b } @item_ids ) { |
| 106 |
|
106 |
|
| 107 |
last if $self->get_from_storage->status eq 'cancelled'; |
107 |
last if $self->get_from_storage->status eq 'cancelled'; |
| 108 |
|
108 |
|
| 109 |
my $item = Koha::Items->find($record_id) || next; |
109 |
my $item = Koha::Items->find($item_id) || next; |
| 110 |
|
110 |
|
| 111 |
my $return = $item->safe_delete({ skip_record_index => 1, skip_holds_queue => 1 }); |
111 |
my $return = $item->safe_delete({ skip_record_index => 1, skip_holds_queue => 1 }); |
| 112 |
unless ( $return ) { |
112 |
unless ( $return ) { |
|
Lines 212-218
sub process {
Link Here
|
| 212 |
|
212 |
|
| 213 |
Koha::BackgroundJob::BatchDeleteItem->new->enqueue( |
213 |
Koha::BackgroundJob::BatchDeleteItem->new->enqueue( |
| 214 |
{ |
214 |
{ |
| 215 |
record_ids => \@itemnumbers, |
215 |
item_ids => \@itemnumbers, |
| 216 |
deleted_biblios => 0|1, |
216 |
deleted_biblios => 0|1, |
| 217 |
} |
217 |
} |
| 218 |
); |
218 |
); |
|
Lines 225-240
sub enqueue {
Link Here
|
| 225 |
my ( $self, $args ) = @_; |
225 |
my ( $self, $args ) = @_; |
| 226 |
|
226 |
|
| 227 |
# TODO Raise exception instead |
227 |
# TODO Raise exception instead |
| 228 |
return unless exists $args->{record_ids}; |
228 |
return unless exists $args->{item_ids}; |
| 229 |
|
229 |
|
| 230 |
my @record_ids = @{ $args->{record_ids} }; |
230 |
my @item_ids = @{ $args->{item_ids} }; |
| 231 |
my $delete_biblios = $args->{delete_biblios} || 0; |
231 |
my $delete_biblios = $args->{delete_biblios} || 0; |
| 232 |
|
232 |
|
| 233 |
$self->SUPER::enqueue( |
233 |
$self->SUPER::enqueue( |
| 234 |
{ |
234 |
{ |
| 235 |
job_size => scalar @record_ids, |
235 |
job_size => scalar @item_ids, |
| 236 |
job_args => { |
236 |
job_args => { |
| 237 |
record_ids => \@record_ids, |
237 |
item_ids => \@item_ids, |
| 238 |
delete_biblios => $delete_biblios, |
238 |
delete_biblios => $delete_biblios, |
| 239 |
}, |
239 |
}, |
| 240 |
queue => 'long_tasks', |
240 |
queue => 'long_tasks', |