Bugzilla – Attachment 124126 Details for
Bug 26860
Add search limit for records without items
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 26860: Add without items facet
Bug-26860-Add-without-items-facet.patch (text/plain), 7.03 KB, created by
Fridolin Somers
on 2021-08-26 22:09:53 UTC
(
hide
)
Description:
Bug 26860: Add without items facet
Filename:
MIME Type:
Creator:
Fridolin Somers
Created:
2021-08-26 22:09:53 UTC
Size:
7.03 KB
patch
obsolete
>From 3aaade28f0ab9e15be787ef5d96fad7e6425506e Mon Sep 17 00:00:00 2001 >From: Fridolin Somers <fridolin.somers@biblibre.com> >Date: Tue, 27 Oct 2020 12:21:32 +0100 >Subject: [PATCH] Bug 26860: Add without items facet >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >Many libraries ask for a way to search biblio records without items. >In order to clean the catalogue or acquire items. >I propose to add a search limit and facet. >Only in staff interface for start. > >I choose to use homebranch index, should always be defined on items. >Looks like itemnumber index can not be used because of its configuration in ccl.properties. > >Test plan : >1) Check with both Zebra and Elasticsearch >2) Perform a search on staff interface returning some records with and some without items >3) Click on 'Limit to records without items' >4) Check you see only records without items >5) Click on 'Show all records' >6) Check you see all records again > >Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr> >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> > >Signed-off-by: David Nind <david@davidnind.com> >--- > C4/Search.pm | 11 +++++++++++ > Koha/SearchEngine/Elasticsearch/QueryBuilder.pm | 3 +++ > catalogue/search.pl | 13 +++++++++++-- > koha-tmpl/intranet-tmpl/prog/en/includes/facets.inc | 11 +++++++++++ > .../prog/en/modules/catalogue/advsearch.tt | 5 ++++- > 5 files changed, 40 insertions(+), 3 deletions(-) > >diff --git a/C4/Search.pm b/C4/Search.pm >index 72c81ec06c..185d715e5a 100644 >--- a/C4/Search.pm >+++ b/C4/Search.pm >@@ -1242,6 +1242,7 @@ sub buildQuery { > } > $q .= ' and '.join(' and ', @limits) if @limits; > } >+ #TODO withoutitems limit > return ( undef, $q, $q, "q=ccl=".uri_escape_utf8($q), $original_q, '', '', '', 'ccl' ); > } > if ( $query =~ /^cql=/ ) { >@@ -1441,6 +1442,7 @@ sub buildQuery { > # add limits > my %group_OR_limits; > my $availability_limit; >+ my $withoutitems_limit; > foreach my $this_limit (@limits) { > next unless $this_limit; > if ( $this_limit =~ /available/ ) { >@@ -1453,6 +1455,11 @@ sub buildQuery { > $limit_cgi .= "&limit=available"; > $limit_desc .= ""; > } >+ elsif ( $this_limit =~ /withoutitems/ ) { >+ $withoutitems_limit = "( allrecords,AlwaysMatches='' not(homebranch,AlwaysMatches='') )"; >+ $limit_cgi .= "&limit=withoutitems"; >+ $limit_desc .= ""; >+ } > > # group_OR_limits, prefixed by mc- > # OR every member of the group >@@ -1497,6 +1504,10 @@ sub buildQuery { > $limit .= " and " if ( $query || $limit ); > $limit .= "($availability_limit)"; > } >+ if ($withoutitems_limit) { >+ $limit .= " and " if ( $query || $limit ); >+ $limit .= "($withoutitems_limit)"; >+ } > > # Normalize the query and limit strings > # This is flawed , means we can't search anything with : in it >diff --git a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm >index 2a0775d386..74a3c4e3ec 100644 >--- a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm >+++ b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm >@@ -1013,6 +1013,9 @@ sub _fix_limit_special_cases { > elsif ( $l =~ /^available$/ ) { > push @new_lim, 'onloan:false'; > } >+ elsif ( $l =~ /^withoutitems$/ ) { >+ push @new_lim, 'NOT homebranch:*'; >+ } > else { > my ( $field, $term ) = $l =~ /^\s*([\w,-]*?):(.*)/; > $field =~ s/,phr$//; #We are quoting all the limits as phrase, this prevents from quoting again later >diff --git a/catalogue/search.pl b/catalogue/search.pl >index 8ed6ff3181..fc7660162c 100755 >--- a/catalogue/search.pl >+++ b/catalogue/search.pl >@@ -417,13 +417,19 @@ for ( my $i=0; $i<@limits; $i++ ) { > } > } > >-my $available; >+my ($available, $withoutitems); > foreach my $limit(@limits) { > if ($limit =~/available/) { > $available = 1; > } >+ if ($limit =~/withoutitems/) { >+ $withoutitems = 1; >+ } > } >-$template->param(available => $available); >+$template->param( >+ available => $available, >+ withoutitems => $withoutitems, >+); > > # append year limits if they exist > my $limit_yr; >@@ -613,6 +619,9 @@ for (my $i=0;$i<@servers;$i++) { > my $limit_cgi_not_availablity = $limit_cgi; > $limit_cgi_not_availablity =~ s/&limit=available//g; > $template->param(limit_cgi_not_availablity => $limit_cgi_not_availablity); >+ my $limit_cgi_not_withoutitems = $limit_cgi; >+ $limit_cgi_not_withoutitems =~ s/&limit=withoutitems//g; >+ $template->param(limit_cgi_not_withoutitems => $limit_cgi_not_withoutitems); > } > $template->param(limit_cgi => $limit_cgi); > $template->param(query_cgi => $query_cgi); >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/facets.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/facets.inc >index af01c0e88b..8b30203470 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/facets.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/facets.inc >@@ -17,6 +17,17 @@ > [% END %] > </ul> > </li> >+ <li id="withoutitems_id"> >+ <span id="facet-withoutitems">Without items</span> >+ <ul> >+ [% IF ( withoutitems ) %] >+ <li><strong>Showing only without items</strong></li> >+ <li><a href="/cgi-bin/koha/catalogue/search.pl?[% query_cgi | $raw %][% limit_cgi_not_withoutitems | $raw %][% IF ( sort_by ) %]&sort_by=[% sort_by | uri %][% END %]">Show all records</a></li> >+ [% ELSE %] >+ <li><a href="/cgi-bin/koha/catalogue/search.pl?[% query_cgi | $raw %][% limit_cgi | $raw %][% IF ( sort_by ) %]&sort_by=[% sort_by | uri %][% END %]&limit=withoutitems">Limit to records without items</a></li> >+ [% END %] >+ </ul> >+ </li> > [% IF ( related ) %] <li>(related searches: [% FOREACH relate IN related %][% relate.related_search | html %][% END %])</li>[% END %] > > [% FOREACH facets_loo IN facets_loop %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt >index a4d7c6d9d7..87f63b3874 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt >@@ -280,7 +280,10 @@ > <!-- AVAILABILITY LIMITS --> > <fieldset id="availability"><legend>Location and availability</legend> > <fieldset id="currently-avail"> >- <p><label for="available-items">Only items currently available:</label> <input type="checkbox" id="available-items" name="limit" value="available" /></p> >+ <p> >+ <label for="available-items">Only items currently available:</label> <input type="checkbox" id="available-items" name="limit" value="available" /> >+ <label for="withoutitems">Only records without items:</label> <input type="checkbox" id="withoutitems" name="limit" value="withoutitems" /> >+ </p> > </fieldset> > > <fieldset id="select-libs"> >-- >2.32.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 26860
:
112858
|
112859
|
112913
|
112914
|
112931
|
112932
|
113220
|
119112
|
119113
|
119114
|
120994
|
124125
| 124126 |
124127