View | Details | Raw Unified | Return to bug 30725
Collapse All | Expand All

(-)a/Koha/BackgroundJob/BatchDeleteItem.pm (-10 / +10 lines)
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',
(-)a/t/db_dependent/Koha/BackgroundJobs/BatchDeleteItem.t (-4 / +4 lines)
Lines 57-63 subtest "process() tests" => sub { Link Here
57
            borrowernumber => undef,
57
            borrowernumber => undef,
58
            type           => 'batch_item_record_deletion',
58
            type           => 'batch_item_record_deletion',
59
            data           => encode_json {
59
            data           => encode_json {
60
                record_ids     => [ $item_1->id, $item_2->id ],
60
                item_ids       => [ $item_1->id, $item_2->id ],
61
                delete_biblios => 1,
61
                delete_biblios => 1,
62
            }
62
            }
63
        }
63
        }
Lines 65-71 subtest "process() tests" => sub { Link Here
65
65
66
    $job->process(
66
    $job->process(
67
        {
67
        {
68
            record_ids     => [ $item_1->id, $item_2->id ],
68
            item_ids       => [ $item_1->id, $item_2->id ],
69
            delete_biblios => 1,
69
            delete_biblios => 1,
70
        }
70
        }
71
    );
71
    );
Lines 84-90 subtest "process() tests" => sub { Link Here
84
            borrowernumber => undef,
84
            borrowernumber => undef,
85
            type           => 'batch_item_record_deletion',
85
            type           => 'batch_item_record_deletion',
86
            data           => encode_json {
86
            data           => encode_json {
87
                record_ids     => [ $item->id ],
87
                item_ids       => [ $item->id ],
88
                delete_biblios => 1,
88
                delete_biblios => 1,
89
            }
89
            }
90
        }
90
        }
Lines 92-98 subtest "process() tests" => sub { Link Here
92
92
93
    $job->process(
93
    $job->process(
94
        {
94
        {
95
            record_ids     => [ $item->id ],
95
            item_ids       => [ $item->id ],
96
            delete_biblios => 1,
96
            delete_biblios => 1,
97
        }
97
        }
98
    );
98
    );
(-)a/tools/batchMod.pl (-2 / +1 lines)
Lines 90-96 if ( $op eq "action" ) { Link Here
90
    if ($del) {
90
    if ($del) {
91
        try {
91
        try {
92
            my $params = {
92
            my $params = {
93
                record_ids     => \@itemnumbers,
93
                item_ids     => \@itemnumbers,
94
                delete_biblios => $del_records,
94
                delete_biblios => $del_records,
95
            };
95
            };
96
            my $job_id =
96
            my $job_id =
97
- 

Return to bug 30725