From 548238345b62fcd9a483de6e2ebd396bcd2127d8 Mon Sep 17 00:00:00 2001 From: Emmi Takkinen Date: Fri, 18 Nov 2022 15:43:46 +0200 Subject: [PATCH] Bug 32266: Add new syspref DefaultLateOrderFilterDaysAgo Some libraries might have large amounts of late orders that slow down opening the lateorders.pl. E.g. patch of 2000 orders takes about 40 seconds to open, larger patches lead to a proxy error. This patch adds new syspref DefaultLateOrderFilterDaysAgo. With this libraries can control how many days old late orders should be for them to show in late orders listing. To test: 1. Open browsers console (F12) and from there Network tab. 2. Navigate to Acquisitions -> Late Orders. => Take a note from browsers console how long it takes to open late orders listing. 3. Apply this patch, update you database and restart your services if needed. 4. Set some value to syspref DefaultLateOrderFilterDaysAgo (999 is max). 5. Load Late orders page again. => Loading page should now be significantly faster. => Only orders which Sponsored-by: Koha-Suomi Oy --- acqui/lateorders.pl | 2 +- installer/data/mysql/atomicupdate/bug_32266.pl | 16 ++++++++++++++++ installer/data/mysql/mandatory/sysprefs.sql | 1 + .../admin/preferences/staff_interface.pref | 6 ++++++ 4 files changed, 24 insertions(+), 1 deletion(-) create mode 100755 installer/data/mysql/atomicupdate/bug_32266.pl diff --git a/acqui/lateorders.pl b/acqui/lateorders.pl index 7ce5683ae5..6ab2a5744b 100755 --- a/acqui/lateorders.pl +++ b/acqui/lateorders.pl @@ -64,7 +64,7 @@ my ($template, $loggedinuser, $cookie) = get_template_and_user( ); my $booksellerid = $input->param('booksellerid'); -my $delay = $input->param('delay') // 0; +my $delay = $input->param('delay') // C4::Context->preference('DefaultLateOrderFilterDaysAgo'); # Get the "date from" param if !defined is today my $estimateddeliverydatefrom = $input->param('estimateddeliverydatefrom'); diff --git a/installer/data/mysql/atomicupdate/bug_32266.pl b/installer/data/mysql/atomicupdate/bug_32266.pl new file mode 100755 index 0000000000..df92b13581 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_32266.pl @@ -0,0 +1,16 @@ +use Modern::Perl; + +return { + bug_number => "32266", + description => "Add syspref DefaultLateOrderFilterDaysAgo", + up => sub { + my ($args) = @_; + my ($dbh, $out) = @$args{qw(dbh out)}; + # Do you stuffs here + $dbh->do(q{ + INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('DefaultLateOrderFilterDaysAgo', '0', NULL, 'How many days ago late orders are displayed', 'integer') + }); + # Print useful stuff here + say $out "Added syspref DefaultLateOrderFilterDaysAgo"; + }, +}; diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index beebd27a6f..60631f07d4 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -176,6 +176,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('DefaultHoldExpirationdateUnitOfTime','days','days|months|years','Which unit of time is used when setting the default expiration date. ','choice'), ('DefaultHoldPickupLocation','loggedinlibrary','loggedinlibrary|homebranch|holdingbranch','Which branch should a hold pickup location default to. ','choice'), ('DefaultLanguageField008','','','Fill in the default language for field 008 Range 35-37 of MARC21 records (e.g. eng, nor, ger, see MARC Code List for Languages)','Free'), +('DefaultLateOrderFilterDaysAgo', '0', NULL, 'How many days ago late orders are displayed', 'integer'), ('DefaultLongOverdueSkipLostStatuses', '', NULL, 'Skip these lost statuses by default in longoverdue.pl', 'Free'), ('DefaultLongOverdueChargeValue', '', NULL, "Charge a lost item to the borrower's account when the LOST value of the item changes to n.", 'integer'), ('DefaultLongOverdueDays', '', NULL, "Set the LOST value of an item when the item has been overdue for more than n days.", 'integer'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/staff_interface.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/staff_interface.pref index 0e5bb27f4c..fc33edf0b6 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/staff_interface.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/staff_interface.pref @@ -199,6 +199,12 @@ Staff interface: 1: Show 0: "Don't show" - a search field pulldown for 'Search the catalog' boxes. + - + - By default, show late orders older than + - pref: DefaultLateOrderFilterDaysAgo + default: 0 + class: integer + - days (999 days being max). Authentication: - - pref: staffShibOnly -- 2.34.1