Summary: | Add an optional default manageddate filter to speed up loading suggestions | ||
---|---|---|---|
Product: | Koha | Reporter: | Marcel de Rooy <m.de.rooy> |
Component: | Staff interface | Assignee: | Bugs List <koha-bugs> |
Status: | NEW --- | QA Contact: | Testopia <testopia> |
Severity: | enhancement | ||
Priority: | P5 - low | CC: | gmcharlt, pedro.amorim |
Version: | Main | ||
Hardware: | All | ||
OS: | All | ||
Change sponsored?: | --- | Patch complexity: | --- |
Documentation contact: | Documentation submission: | ||
Text to go in the release notes: | Version(s) released in: | ||
Circulation function: | |||
Attachments: | Bug 39239: Speed up loading suggestions with manageddate filter |
Description
Marcel de Rooy
2025-03-04 15:47:48 UTC
Already tested this tiny change with a local use pref: diff --git a/suggestion/suggestion.pl b/suggestion/suggestion.pl index 2090a8a..f221bc7 100755 --- a/suggestion/suggestion.pl +++ b/suggestion/suggestion.pl @@ -409,6 +409,10 @@ if ($op=~/else/) { my $from_dt = $from && eval { dt_from_string($from) }; my $to_dt = $to && eval { dt_from_string($to) }; + if ( ( my $from_pref = C4::Context->preference('SuggestionsDefaultManagedFrom') ) && $field eq 'manageddate' ) { + $from_dt ||= dt_from_string()->subtract( days => $from_pref ); + $template->param( "${field}_from" => $from_dt ); + } if ( $from_dt || $to_dt ) { my $dtf = Koha::Database->new->schema->storage->datetime_parser; if ( $from_dt && $to_dt ) { The above SuggestionsDefaultManagedFrom is the age in days that you want to limit suggestions by, looking at manageddate. And with this tiny change, the Suggestions filter opens up to indicate that we added a default filter: diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt index ffa2363..098aa56 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt @@ -1450,6 +1450,9 @@ return true; }); }); + [% IF manageddate_from %] + $("fieldset.suggestion_information").toggle(); + [% END %] </script> [% END %] [% IF op == 'save' %] So yes, this is kind of a 'low budget' workaround to not refactor the whole thing rightaway (which is much more work). Although we are fetching say 100-200 records, it still takes too much time. If you have over 1000, you probably time out. Created attachment 178976 [details] [review] Bug 39239: Speed up loading suggestions with manageddate filter Current patch just illustrates this workaround. We actually need larger refactoring. |