Bugzilla – Attachment 123226 Details for
Bug 28445
Use the task queue for the batch delete and update items tool
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 28445: Add the capability to provide more info to the background job detail view
Bug-28445-Add-the-capability-to-provide-more-info-.patch (text/plain), 4.94 KB, created by
Jonathan Druart
on 2021-07-27 16:40:26 UTC
(
hide
)
Description:
Bug 28445: Add the capability to provide more info to the background job detail view
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2021-07-27 16:40:26 UTC
Size:
4.94 KB
patch
obsolete
>From 0af43bf85db17f8e84ee772bb494fe1224c33dc7 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 26 Jul 2021 19:22:29 +0200 >Subject: [PATCH] Bug 28445: Add the capability to provide more info to the > background job detail view > >We already had the need for that, when bibliographic records are >modified in batch we wanted to add a "Add to list" feature, and so pass >a list of lists/virtual shelves to the template. > >Here we will want to pass the infos of the items that have been modified >to display a table. >--- > Koha/BackgroundJob.pm | 48 +++++++++++++++++++------ > Koha/BackgroundJob/BatchUpdateBiblio.pm | 23 ++++++++++++ > t/db_dependent/Koha/BackgroundJobs.t | 8 ++++- > 3 files changed, 68 insertions(+), 11 deletions(-) > >diff --git a/Koha/BackgroundJob.pm b/Koha/BackgroundJob.pm >index 1498f51de63..553d7ce6e64 100644 >--- a/Koha/BackgroundJob.pm >+++ b/Koha/BackgroundJob.pm >@@ -152,16 +152,14 @@ Process the job! > sub process { > my ( $self, $args ) = @_; > >- my $job_type = $self->type; >- return $job_type eq 'batch_biblio_record_modification' >- ? Koha::BackgroundJob::BatchUpdateBiblio->process($args) >- : $job_type eq 'batch_authority_record_modification' >- ? Koha::BackgroundJob::BatchUpdateAuthority->process($args) >- : $job_type eq 'batch_biblio_record_deletion' >- ? Koha::BackgroundJob::BatchDeleteBiblio->process($args) >- : $job_type eq 'batch_authority_record_deletion' >- ? Koha::BackgroundJob::BatchDeleteAuthority->process($args) >- : Koha::Exceptions::Exception->throw('->process called without valid job_type'); >+ return {} if ref($self) ne 'Koha::BackgroundJob'; >+ >+ my $derived_class = $self->_derived_class; >+ >+ $args ||= {}; >+ >+ return $derived_class->process({job_id => $self->id, %$args}); >+ > } > > =head3 job_type >@@ -203,6 +201,22 @@ sub report { > return $data_dump->{report}; > } > >+=head3 additional_report >+ >+Build additional variables for the job detail view. >+ >+=cut >+ >+sub additional_report { >+ my ( $self ) = @_; >+ >+ return {} if ref($self) ne 'Koha::BackgroundJob'; >+ >+ my $derived_class = $self->_derived_class; >+ >+ return $derived_class->additional_report({job_id => $self->id}); >+} >+ > =head3 cancel > > Cancel a job. >@@ -214,6 +228,20 @@ sub cancel { > $self->status('cancelled')->store; > } > >+sub _derived_class { >+ my ( $self ) = @_; >+ my $job_type = $self->type; >+ return $job_type eq 'batch_biblio_record_modification' >+ ? Koha::BackgroundJob::BatchUpdateBiblio->new >+ : $job_type eq 'batch_authority_record_modification' >+ ? Koha::BackgroundJob::BatchUpdateAuthority->new >+ : $job_type eq 'batch_biblio_record_deletion' >+ ? Koha::BackgroundJob::BatchDeleteBiblio->new >+ : $job_type eq 'batch_authority_record_deletion' >+ ? Koha::BackgroundJob::BatchDeleteAuthority->new >+ : Koha::Exceptions::Exception->throw($job_type . ' is not a valid job_type') >+} >+ > sub _type { > return 'BackgroundJob'; > } >diff --git a/Koha/BackgroundJob/BatchUpdateBiblio.pm b/Koha/BackgroundJob/BatchUpdateBiblio.pm >index 9371e2212ff..34f732978a3 100644 >--- a/Koha/BackgroundJob/BatchUpdateBiblio.pm >+++ b/Koha/BackgroundJob/BatchUpdateBiblio.pm >@@ -20,6 +20,9 @@ use JSON qw( decode_json encode_json ); > > use Koha::BackgroundJobs; > use Koha::DateUtils qw( dt_from_string ); >+use Koha::Virtualshelves; >+ >+use C4::Context; > use C4::Biblio; > use C4::MarcModificationTemplates; > >@@ -140,4 +143,24 @@ sub enqueue { > }); > } > >+=head3 additional_report >+ >+Pass the list of lists/virtual shelves the logged in user has write permissions. >+ >+It will enable the "add modified records to list" feature. >+ >+=cut >+ >+sub additional_report { >+ my ($self) = @_; >+ >+ my $loggedinuser = C4::Context->userenv ? C4::Context->userenv->{'number'} : undef; >+ return { >+ lists => scalar Koha::Virtualshelves->search( >+ [ { category => 1, owner => $loggedinuser }, { category => 2 } ] >+ ), >+ }; >+ >+} >+ > 1; >diff --git a/t/db_dependent/Koha/BackgroundJobs.t b/t/db_dependent/Koha/BackgroundJobs.t >index f678e206357..ce753683605 100755 >--- a/t/db_dependent/Koha/BackgroundJobs.t >+++ b/t/db_dependent/Koha/BackgroundJobs.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 11; >+use Test::More tests => 12; > use Test::MockModule; > use JSON qw( decode_json ); > >@@ -40,6 +40,10 @@ t::lib::Mocks::mock_userenv; > my $net_stomp = Test::MockModule->new('Net::Stomp'); > $net_stomp->mock( 'send_with_receipt', sub { return 1 } ); > >+my $background_job_module = Test::MockModule->new('Koha::BackgroundJob'); >+$background_job_module->mock( '_derived_class', >+ sub { t::lib::Koha::BackgroundJob::BatchTest->new } ); >+ > my $data = { a => 'aaa', b => 'bbb' }; > my $job_size = 10; > my $job_id = t::lib::Koha::BackgroundJob::BatchTest->new->enqueue( >@@ -80,4 +84,6 @@ is_deeply( > 'Correct number of records processed' > ); > >+is_deeply( $new_job->additional_report(), {} ); >+ > $schema->storage->txn_rollback; >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 28445
:
121372
|
123221
|
123222
|
123223
|
123224
|
123225
|
123226
|
123227
|
123228
|
123229
|
123239
|
123240
|
125801
|
125802
|
125803
|
125804
|
125805
|
125808
|
125810
|
125811
|
125812
|
125817
|
125865
|
126046
|
126047
|
126136
|
126137
|
126138
|
126139
|
126140
|
126141
|
126142
|
126217
|
126218
|
126219
|
126223
|
126328
|
126329
|
126330
|
126331
|
126332
|
126333
|
126334
|
126335
|
126336
|
126337
|
126338
|
126339
|
126352
|
126353
|
126354
|
126355
|
126356
|
126357
|
126358
|
126359
|
126360
|
126361
|
126362
|
126363
|
126364
|
126365
|
126366
|
126367
|
126374
|
126375
|
126376
|
126377
|
126378
|
126379
|
126380
|
126381
|
126382
|
126383
|
126384
|
126385
|
126386
|
126387
|
126388
|
126389
|
127033
|
127037
|
127038
|
127039
|
128007
|
128008
|
128009