Bugzilla – Attachment 123599 Details for
Bug 28826
Facet sort order differs between search engines
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 28826: Add FacetOrder system preference
Bug-28826-Add-FacetOrder-system-preference.patch (text/plain), 5.14 KB, created by
David Nind
on 2021-08-08 17:46:51 UTC
(
hide
)
Description:
Bug 28826: Add FacetOrder system preference
Filename:
MIME Type:
Creator:
David Nind
Created:
2021-08-08 17:46:51 UTC
Size:
5.14 KB
patch
obsolete
>From 91400fedfc3bec0b7c6aa2ff051b5e7807fc8386 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Fri, 6 Aug 2021 18:50:35 +0000 >Subject: [PATCH] Bug 28826: Add FacetOrder system preference > >This bug adds a system preference to control ordering of facets and >adds the control to both Zebra and Elasticsearch > >To test: >1 - Have a koha that can use both Zebra and ES >2 - Set 'displayFacetCount' to true >3 - Search in ES and Zebra >4 - Note facets in Zebra sorted alphabetically, ES by usage >5 - Apply patch, updatedatabase >6 - Search in ES and Zebra, facets are alphabetically sorted in both >7 - Find new syspref FacetOrder and set to 'by usage' >8 - Search in both engines, facets sorted by usage > >Signed-off-by: David Nind <david@davidnind.com> >--- > C4/Search.pm | 5 ++++- > Koha/SearchEngine/Elasticsearch/Search.pm | 5 +++++ > .../atomicupdate/bug_28826_add_FacetSort_syspref.perl | 9 +++++++++ > installer/data/mysql/mandatory/sysprefs.sql | 1 + > .../prog/en/modules/admin/preferences/searching.pref | 9 +++++++++ > 5 files changed, 28 insertions(+), 1 deletion(-) > create mode 100644 installer/data/mysql/atomicupdate/bug_28826_add_FacetSort_syspref.perl > >diff --git a/C4/Search.pm b/C4/Search.pm >index 1ca987add2..503ce6ee09 100644 >--- a/C4/Search.pm >+++ b/C4/Search.pm >@@ -586,7 +586,10 @@ sub getRecords { > # This sorts the facets into alphabetical order > if (@facets_loop) { > foreach my $f (@facets_loop) { >- $f->{facets} = [ sort { uc($a->{facet_label_value}) cmp uc($b->{facet_label_value}) } @{ $f->{facets} } ]; >+ if( C4::Context->preference('FacetOrder') eq 'Alphabetical' ){ >+ $f->{facets} = >+ [ sort { uc($a->{facet_label_value}) cmp uc($b->{facet_label_value}) } @{ $f->{facets} } ]; >+ } > } > } > >diff --git a/Koha/SearchEngine/Elasticsearch/Search.pm b/Koha/SearchEngine/Elasticsearch/Search.pm >index 3afcf75c37..e753220948 100644 >--- a/Koha/SearchEngine/Elasticsearch/Search.pm >+++ b/Koha/SearchEngine/Elasticsearch/Search.pm >@@ -500,9 +500,14 @@ sub _convert_facets { > type_link_value => $type, > }; > } >+ if( C4::Context->preference('FacetOrder') eq 'Alphabetical' ){ >+ @{ $facet->{facets} } = >+ sort { $a->{facet_label_value} cmp $b->{facet_label_value} } @{ $facet->{facets} }; >+ } > push @facets, $facet if exists $facet->{facets}; > } > >+ > @facets = sort { $a->{order} <=> $b->{order} } @facets; > return \@facets; > } >diff --git a/installer/data/mysql/atomicupdate/bug_28826_add_FacetSort_syspref.perl b/installer/data/mysql/atomicupdate/bug_28826_add_FacetSort_syspref.perl >new file mode 100644 >index 0000000000..c69a0f9454 >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug_28826_add_FacetSort_syspref.perl >@@ -0,0 +1,9 @@ >+$DBversion = 'XXX'; >+if( CheckVersion( $DBversion ) ) { >+ $dbh->do(q{ >+ INSERT IGNORE INTO systempreferences >+ ( variable, value, options, explanation, type ) VALUES >+ ('FacetOrder','Alphabetical','Alphabetical|Usage','Specify the order of facets within each category','Choice') >+ }); >+ NewVersion( $DBversion, 28826, "Add system preference FacetOrder"); >+} >diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql >index 6b66e42c14..9781c385bc 100644 >--- a/installer/data/mysql/mandatory/sysprefs.sql >+++ b/installer/data/mysql/mandatory/sysprefs.sql >@@ -210,6 +210,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` > ('ExtendedPatronAttributes','1',NULL,'Use extended patron IDs and attributes','YesNo'), > ('FacetLabelTruncationLength','20',NULL,'Specify the facet max length in OPAC','Integer'), > ('FacetMaxCount','20',NULL,'Specify the max facet count for each category','Integer'), >+('FacetOrder','Alphabetical','Alphabetical|Usage','Specify the order of facets within each category','Choice'), > ('FailedLoginAttempts','','','Number of login attempts before lockout the patron account','Integer'), > ('FallbackToSMSIfNoEmail', 0, 'Enable|Disable', 'Send messages by SMS if no patron email is defined', 'YesNo'), > ('FeeOnChangePatronCategory','1','','If set, when a patron changes to a category with enrolment fee, a fee is charged','YesNo'), >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref >index 25b3878307..5b9df1bc72 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref >@@ -231,6 +231,15 @@ Searching: > class: integer > default: 20 > - facets for each category. >+ - >+ - Sort facets >+ - pref: FacetOrder >+ type: choice >+ choices: >+ Alphabetical: "alphabetically" >+ Usage: "by usage count" >+ default: Alphabetical >+ - for each category. > - > - By default, show > - pref: OPACnumSearchResults >-- >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 28826
:
123586
|
123599
|
125286