Bugzilla – Attachment 98253 Details for
Bug 24027
Adding multiple items is slow
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24027: (follow-up) Don't combine multiple items add POST page with list generation
Bug-24027-follow-up-Dont-combine-multiple-items-ad.patch (text/plain), 7.09 KB, created by
Michal Denar
on 2020-01-31 21:23:56 UTC
(
hide
)
Description:
Bug 24027: (follow-up) Don't combine multiple items add POST page with list generation
Filename:
MIME Type:
Creator:
Michal Denar
Created:
2020-01-31 21:23:56 UTC
Size:
7.09 KB
patch
obsolete
>From d44c47ce6483e2da00372d34421ad7d83137e15d Mon Sep 17 00:00:00 2001 >From: Andrew Nugged <nugged@gmail.com> >Date: Thu, 21 Nov 2019 16:46:36 +0200 >Subject: [PATCH] Bug 24027: (follow-up) Don't combine multiple items add POST > page with list generation > >When hundreds or thousands of items added, it takes time to add to DB. >Then generation of items list in the SAME request also takes time. >This "doubles" page generation time. > >This patch proposes to show only the number of added and total items on >POST-generated page instead of list generation, but not always: >only if some limit are reached ("OpacMaxItemsToDisplay" // 50 is used), >and propose navigation link for the user to see the list after. > >It's much more sensible on big databases and libraries hosting/clouds >with limited resources even up to page generation timeout. > >This stacks up with previous patch for the combined speed up effect. > >Other improvements with this patch: > >because added counters for both: >- added now items, >- overall items for this biblioid in DB, >it is now shows: >- number of added items after adding in "dialog message" style box, >- number of total displayed items on the beginning of the list table. > >Signed-off-by: Michal Denar <black23@gmail.com> >--- > cataloguing/additem.pl | 49 +++++++++++++++++++++- > .../prog/en/modules/cataloguing/additem.tt | 15 +++++++ > 2 files changed, 63 insertions(+), 1 deletion(-) > >diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl >index cb26db28a7..b0c289a2a7 100755 >--- a/cataloguing/additem.pl >+++ b/cataloguing/additem.pl >@@ -397,6 +397,9 @@ my $fa_duedatespec = $input->param('duedatespec'); > > my $frameworkcode = &GetFrameworkCode($biblionumber); > >+# counter for multiple added items to put into template >+my $num_items_added = 0; >+ > # Defining which userflag is needing according to the framework currently used > my $userflags; > if (defined $input->param('frameworkcode')) { >@@ -517,6 +520,7 @@ if ($op eq "additem") { > $cookie = [ $cookie, $itemcookie ]; > } > >+ $num_items_added++; > } > $nextop = "additem"; > if ($exist_itemnumber) { >@@ -538,7 +542,8 @@ if ($op eq "additem") { > $fieldItem->delete_subfields($tagsubfield); > $itemrecord->insert_fields_ordered($fieldItem); > } >- $itemrecord = removeFieldsForPrefill($itemrecord) if ($prefillitem); >+ $itemrecord = removeFieldsForPrefill($itemrecord) if ($prefillitem); >+ $num_items_added++; > } > > # If we have to add multiple copies >@@ -610,6 +615,8 @@ if ($op eq "additem") { > $i++; > # Only increment copynumber if item was really added > $copynumber++ if ( $copynumber && $copynumber =~ m/^\d+$/ ); >+ >+ $num_items_added++; > } > > # Preparing the next iteration >@@ -760,6 +767,44 @@ if ($op eq "additem") { > # build screen with existing items. and "new" one > #------------------------------------------------------------------------------- > >+my $items_counter = Koha::Items->count( {biblionumber => $biblionumber} ); >+ >+# Don't display if that was additems mode request and too big list limt is reached, >+# for not to make POST page load so long because adding items takes time + generation too >+my $max_items_to_display_on_add = C4::Context->preference('OpacMaxItemsToDisplay') // 50; >+if( $num_items_added > 0 and $items_counter > $max_items_to_display_on_add ) { >+ # another call of template with empty sets (full call when list generated is down below) >+ $template->param( >+ biblionumber => $biblionumber, >+ title => $oldrecord->{title}, >+ author => $oldrecord->{author}, >+ num_items_added => $num_items_added, >+ items_counter => $items_counter, >+ dont_display_after_add => 1, >+ item_loop => \(), >+ item_header_loop => \(), >+ item => \(), >+ itemnumber => $itemnumber, >+ barcode => undef, >+ itemtagfield => undef, >+ itemtagsubfield => undef, >+ op => $nextop, >+ popup => scalar $input->param('popup') ? 1 : 0, >+ C4::Search::enabled_staff_search_views, >+ ); >+ $template->{'VARS'}->{'searchid'} = $searchid; >+ >+ foreach my $error (@errors) { >+ $template->param( $error => 1 ); >+ } >+ output_html_with_http_headers $input, $cookie, $template->output; >+ >+ # we stop here, template is generated >+ exit; >+} >+ >+ >+ > # now, build existiing item list > my $temp = GetMarcBiblio({ biblionumber => $biblionumber }); > #my @fields = $record->fields(); >@@ -945,6 +990,8 @@ $template->param( > biblionumber => $biblionumber, > title => $oldrecord->{title}, > author => $oldrecord->{author}, >+ num_items_added => $num_items_added, >+ items_counter => $items_counter, > item_loop => \@item_value_loop, > item_header_loop => \@header_value_loop, > item => \@loop_data, >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt >index 641053149c..1c4ce7764e 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt >@@ -42,9 +42,21 @@ > [% IF ( not_same_branch ) %]<div class="dialog alert"><strong>Cannot delete</strong>: The items do not belong to your library.</div>[% END %] > [% IF ( linked_analytics ) %]<div class="dialog alert"><strong>Cannot delete</strong>: item has linked <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblionumber | uri %]&analyze=1">analytics.</a>.</div>[% END %] > >+[% IF num_items_added %] >+<div class="dialog message"> >+ <h3><strong>[% num_items_added | html %]</strong> item(s) added</h3> >+</div> >+[% END %] >+[% IF dont_display_after_add %] >+<div class="dialog message"> >+ <h4>Items list is too big (<strong>[% items_counter | html %]</strong>) to display on post-adding page,</h4> >+ <a href="/cgi-bin/koha/cataloguing/additem.pl?biblionumber=[% biblionumber %]">Return to the list</a> >+</div> >+[% ELSE %] > <div id="cataloguing_additem_itemlist"> > [% IF ( item_loop ) %] > <div> >+ <h3>Displaying [% items_counter | html %] items:</h3> > <table id="itemst"> > <thead> > <tr> >@@ -113,6 +125,7 @@ > </table> > </div> > [% END %] >+[% END %] > > <div class="row"> > <div class="col-sm-2"> >@@ -120,6 +133,7 @@ > </div> > <div class="col-sm-10"> > >+[% IF NOT dont_display_after_add %] > <div id="cataloguing_additem_newitem"> > <form id="f" method="post" action="/cgi-bin/koha/cataloguing/additem.pl?biblionumber=[% biblionumber | html %]" name="f"> > <input type="hidden" name="op" value="[% op | html %]" /> >@@ -249,6 +263,7 @@ > > </form> > </div> <!-- /#cataloguing_additem_newitem --> >+[% END %] > </div> <!-- /.col-sm-10 --> > </div> <!-- /.row --> > </div> <!-- /#cataloguing_additem_itemlist --> >-- >2.11.0
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 24027
:
95413
|
95414
|
95417
|
95446
|
95473
|
95663
|
98250
|
98251
|
98252
|
98253
|
102464
|
102474
|
102567
|
102568
|
102572
|
102578
|
102579
|
102580