Lines 20-25
use Modern::Perl;
Link Here
|
20 |
use JSON qw( encode_json decode_json ); |
20 |
use JSON qw( encode_json decode_json ); |
21 |
use Try::Tiny; |
21 |
use Try::Tiny; |
22 |
|
22 |
|
|
|
23 |
use Koha::Biblios; |
23 |
use Koha::Exceptions; |
24 |
use Koha::Exceptions; |
24 |
|
25 |
|
25 |
use C4::HoldsQueue |
26 |
use C4::HoldsQueue |
Lines 59-70
sub process {
Link Here
|
59 |
|
60 |
|
60 |
my $schema = Koha::Database->new->schema; |
61 |
my $schema = Koha::Database->new->schema; |
61 |
|
62 |
|
62 |
my $job_progress = 0; |
|
|
63 |
|
64 |
$self->set( |
63 |
$self->set( |
65 |
{ |
64 |
{ |
66 |
started_on => \'NOW()', |
65 |
started_on => \'NOW()', |
67 |
progress => $job_progress, |
66 |
progress => 0, |
68 |
status => 'started', |
67 |
status => 'started', |
69 |
} |
68 |
} |
70 |
)->store; |
69 |
)->store; |
Lines 100-125
sub process {
Link Here
|
100 |
type => 'success', |
99 |
type => 'success', |
101 |
code => 'holds_queue_updated', |
100 |
code => 'holds_queue_updated', |
102 |
biblio_id => $biblio_id, |
101 |
biblio_id => $biblio_id, |
103 |
available_items => $result->{available_items}, |
|
|
104 |
mapped_items => $result->{mapped_items}, |
105 |
requests => $result->{requests}, |
106 |
}; |
102 |
}; |
107 |
$report->{total_success}++; |
103 |
$report->{total_success}++; |
108 |
|
104 |
|
109 |
$schema->storage->txn_commit; |
105 |
$schema->storage->txn_commit; |
110 |
} |
106 |
} |
111 |
catch { |
107 |
catch { |
112 |
push @messages, { |
108 |
|
|
|
109 |
push @messages, |
110 |
{ |
113 |
type => 'error', |
111 |
type => 'error', |
114 |
code => 'holds_queue_update_error', |
112 |
code => 'holds_queue_update_error', |
115 |
biblio_id => $biblio_id, |
113 |
biblio_id => $biblio_id, |
116 |
error => "$_", |
114 |
error => "$_", |
117 |
}; |
115 |
}; |
118 |
|
116 |
|
119 |
$schema->storage->txn_rollback; |
117 |
$schema->storage->txn_rollback; |
120 |
}; |
118 |
}; |
121 |
|
119 |
|
122 |
$self->progress( $job_progress++ )->store; |
120 |
$self->progress( $self->progress + 1 )->store; |
123 |
} |
121 |
} |
124 |
|
122 |
|
125 |
my $job_data = decode_json $self->data; |
123 |
my $job_data = decode_json $self->data; |
Lines 130-141
sub process {
Link Here
|
130 |
{ |
128 |
{ |
131 |
ended_on => \'NOW()', |
129 |
ended_on => \'NOW()', |
132 |
data => encode_json $job_data, |
130 |
data => encode_json $job_data, |
|
|
131 |
status => 'finished', |
133 |
} |
132 |
} |
134 |
); |
133 |
)->store; |
135 |
$self->status('finished') |
|
|
136 |
unless $self->status ne 'cancelled'; |
137 |
|
138 |
$self->store; |
139 |
} |
134 |
} |
140 |
|
135 |
|
141 |
=head3 enqueue |
136 |
=head3 enqueue |