Bugzilla – Attachment 60123 Details for
Bug 18098
Add an index with the count of not onloan items
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18098: Add an index with the count of available items
Bug-18098-Add-an-index-with-the-count-of-available.patch (text/plain), 10.09 KB, created by
Tomás Cohen Arazi (tcohen)
on 2017-02-10 18:06:41 UTC
(
hide
)
Description:
Bug 18098: Add an index with the count of available items
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2017-02-10 18:06:41 UTC
Size:
10.09 KB
patch
obsolete
>From 5edb97fd914618a199e7d752a4c0c657dfe93979 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Fri, 10 Feb 2017 14:57:20 -0300 >Subject: [PATCH] Bug 18098: Add an index with the count of available items > >This patch adds a way to specify which MARC field contains the onloan >status and uses it to generate an XSLT that generates a new index for >Zebra called 'available'. This index contains the amount of items that >have an onloan status different than 1. > >The idea is to change the way we build the query on the Perl side, and >just search for available > 0, taking advantage of DOM indexing >capabilities. > >To test: >- Have a marcxml record containing holdings (952/995 depending on your > MARC flavour). >- Run: > $ xsltproc \ > etc/zebradb/marc_defs/marc21/biblios/biblio-zebra-indexdefs.xsl \ > your_record.marcxml >=> FAIL: There's no 'available' z:index. >- Apply the patch >- Run: > $ xsltproc \ > etc/zebradb/marc_defs/marc21/biblios/biblio-zebra-indexdefs.xsl \ > your_record.marcxml >=> SUCCESS: There's a <z:index> entry for 'available' >- Sign off :-D > >Sponsored-by: ByWater Solutions >--- > .../marc21/biblios/biblio-koha-indexdefs.xml | 2 ++ > .../marc21/biblios/biblio-zebra-indexdefs.xsl | 6 ++++++ > .../normarc/biblios/biblio-koha-indexdefs.xml | 2 ++ > .../normarc/biblios/biblio-zebra-indexdefs.xsl | 6 ++++++ > .../unimarc/biblios/biblio-koha-indexdefs.xml | 2 ++ > .../unimarc/biblios/biblio-zebra-indexdefs.xsl | 21 +++++++++++++++++++++ > etc/zebradb/xsl/koha-indexdefs-to-zebra.xsl | 20 ++++++++++++++++++++ > 7 files changed, 59 insertions(+) > >diff --git a/etc/zebradb/marc_defs/marc21/biblios/biblio-koha-indexdefs.xml b/etc/zebradb/marc_defs/marc21/biblios/biblio-koha-indexdefs.xml >index 49f774aa88..5cdf64b490 100644 >--- a/etc/zebradb/marc_defs/marc21/biblios/biblio-koha-indexdefs.xml >+++ b/etc/zebradb/marc_defs/marc21/biblios/biblio-koha-indexdefs.xml >@@ -1328,6 +1328,8 @@ > <target_index>Note:p</target_index> > </index_subfields> > >+ <onloan_field tag="952" subfield="q"/> >+ > <facet tag="100" subfields="a"> > <target_index>au:0</target_index> > </facet> >diff --git a/etc/zebradb/marc_defs/marc21/biblios/biblio-zebra-indexdefs.xsl b/etc/zebradb/marc_defs/marc21/biblios/biblio-zebra-indexdefs.xsl >index 5feab047fb..9596ae60c0 100644 >--- a/etc/zebradb/marc_defs/marc21/biblios/biblio-zebra-indexdefs.xsl >+++ b/etc/zebradb/marc_defs/marc21/biblios/biblio-zebra-indexdefs.xsl >@@ -44,6 +44,7 @@ definition file (probably something like {biblio,authority}-koha-indexdefs.xml) > <xslo:apply-templates mode="index_subject_thesaurus"/> > <xslo:apply-templates mode="index_all"/> > <xslo:apply-templates mode="index_sort_tit"/> >+ <xslo:call-template name="index_available"/> > </z:record> > </xslo:template> > <xslo:template match="marc:leader"> >@@ -2521,6 +2522,11 @@ definition file (probably something like {biblio,authority}-koha-indexdefs.xml) > </z:index> > </xslo:if> > </xslo:template> >+ <xslo:template name="index_available"> >+ <z:index name="available:n"> >+ <xslo:value-of select="count(marc:datafield[@tag='952']/marc:subfield[@code='q' and not(contains(.,'1'))])"/> >+ </z:index> >+ </xslo:template> > <xslo:template mode="index_all" match="text()"> > <z:index name="Any:w Any:p"> > <xslo:value-of select="."/> >diff --git a/etc/zebradb/marc_defs/normarc/biblios/biblio-koha-indexdefs.xml b/etc/zebradb/marc_defs/normarc/biblios/biblio-koha-indexdefs.xml >index dff2d7514e..4643cd7ae5 100644 >--- a/etc/zebradb/marc_defs/normarc/biblios/biblio-koha-indexdefs.xml >+++ b/etc/zebradb/marc_defs/normarc/biblios/biblio-koha-indexdefs.xml >@@ -969,6 +969,8 @@ > <target_index>itype:w</target_index> > </index_subfields> > >+ <onloan_field tag="952" subfield="q"/> >+ > <facet tag="100" subfields="a"> > <target_index>au:0</target_index> > </facet> >diff --git a/etc/zebradb/marc_defs/normarc/biblios/biblio-zebra-indexdefs.xsl b/etc/zebradb/marc_defs/normarc/biblios/biblio-zebra-indexdefs.xsl >index 301f9a76dc..a3d5ba8e6c 100644 >--- a/etc/zebradb/marc_defs/normarc/biblios/biblio-zebra-indexdefs.xsl >+++ b/etc/zebradb/marc_defs/normarc/biblios/biblio-zebra-indexdefs.xsl >@@ -44,6 +44,7 @@ definition file (probably something like {biblio,authority}-koha-indexdefs.xml) > <xslo:apply-templates mode="index_subject_thesaurus"/> > <xslo:apply-templates mode="index_all"/> > <xslo:apply-templates mode="index_sort_tit"/> >+ <xslo:call-template name="index_available"/> > </z:record> > </xslo:template> > <xslo:template match="marc:leader"> >@@ -1861,6 +1862,11 @@ definition file (probably something like {biblio,authority}-koha-indexdefs.xml) > </z:index> > </xslo:if> > </xslo:template> >+ <xslo:template name="index_available"> >+ <z:index name="available:n"> >+ <xslo:value-of select="count(marc:datafield[@tag='952']/marc:subfield[@code='q' and not(contains(.,'1'))])"/> >+ </z:index> >+ </xslo:template> > <xslo:template mode="index_all" match="text()"> > <z:index name="Any:w Any:p"> > <xslo:value-of select="."/> >diff --git a/etc/zebradb/marc_defs/unimarc/biblios/biblio-koha-indexdefs.xml b/etc/zebradb/marc_defs/unimarc/biblios/biblio-koha-indexdefs.xml >index 90e92a04d3..11800cf44c 100644 >--- a/etc/zebradb/marc_defs/unimarc/biblios/biblio-koha-indexdefs.xml >+++ b/etc/zebradb/marc_defs/unimarc/biblios/biblio-koha-indexdefs.xml >@@ -1444,6 +1444,8 @@ > <target_index>totalissues:s</target_index> > </index_subfields> > >+ <onloan_field tag="995" subfield="n"/> >+ > <facet tag="225" subfields="a"> > <target_index>se:0</target_index> > </facet> >diff --git a/etc/zebradb/marc_defs/unimarc/biblios/biblio-zebra-indexdefs.xsl b/etc/zebradb/marc_defs/unimarc/biblios/biblio-zebra-indexdefs.xsl >index 32e1742804..ca12bc8448 100644 >--- a/etc/zebradb/marc_defs/unimarc/biblios/biblio-zebra-indexdefs.xsl >+++ b/etc/zebradb/marc_defs/unimarc/biblios/biblio-zebra-indexdefs.xsl >@@ -17,6 +17,7 @@ definition file (probably something like {biblio,authority}-koha-indexdefs.xml) > <xslo:template match="text()" mode="index_heading_conditional"/> > <xslo:template match="text()" mode="index_match_heading"/> > <xslo:template match="text()" mode="index_subject_thesaurus"/> >+ <xslo:template match="text()" mode="index_sort_tit"/> > <xslo:template match="/"> > <xslo:if test="marc:collection"> > <collection> >@@ -42,6 +43,8 @@ definition file (probably something like {biblio,authority}-koha-indexdefs.xml) > <xslo:apply-templates mode="index_match_heading"/> > <xslo:apply-templates mode="index_subject_thesaurus"/> > <xslo:apply-templates mode="index_all"/> >+ <xslo:apply-templates mode="index_sort_tit"/> >+ <xslo:call-template name="index_available"/> > </z:record> > </xslo:template> > <xslo:template match="marc:controlfield[@tag='001']"> >@@ -2676,11 +2679,29 @@ definition file (probably something like {biblio,authority}-koha-indexdefs.xml) > </z:index> > </xslo:if> > </xslo:template> >+ <xslo:template name="index_available"> >+ <z:index name="available:n"> >+ <xslo:value-of select="count(marc:datafield[@tag='995']/marc:subfield[@code='n' and not(contains(.,'1'))])"/> >+ </z:index> >+ </xslo:template> > <xslo:template mode="index_all" match="text()"> > <z:index name="Any:w Any:p"> > <xslo:value-of select="."/> > </z:index> > </xslo:template> >+ <xslo:template mode="index_sort_tit" match="marc:datafield[@tag='245']"> >+ <xslo:variable name="chop"> >+ <xslo:choose> >+ <xslo:when test="not(number(@ind2))">0</xslo:when> >+ <xslo:otherwise> >+ <xslo:value-of select="number(@ind2)"/> >+ </xslo:otherwise> >+ </xslo:choose> >+ </xslo:variable> >+ <z:index name="Title:s"> >+ <xslo:value-of select="substring(marc:subfield[@code='a'], $chop+1)"/> >+ </z:index> >+ </xslo:template> > <xslo:template name="chopPunctuation"> > <xslo:param name="chopString"/> > <xslo:variable name="length" select="string-length($chopString)"/> >diff --git a/etc/zebradb/xsl/koha-indexdefs-to-zebra.xsl b/etc/zebradb/xsl/koha-indexdefs-to-zebra.xsl >index 59876caf73..18e3a6ca2d 100644 >--- a/etc/zebradb/xsl/koha-indexdefs-to-zebra.xsl >+++ b/etc/zebradb/xsl/koha-indexdefs-to-zebra.xsl >@@ -67,6 +67,7 @@ definition file (probably something like {biblio,authority}-koha-indexdefs.xml) > <xslo:apply-templates mode="index_subject_thesaurus"/> > <xslo:apply-templates mode="index_all"/> > <xslo:apply-templates mode="index_sort_tit"/> >+ <xslo:call-template name="index_available"/> > </z:record> > </xslo:template> > >@@ -78,6 +79,7 @@ definition file (probably something like {biblio,authority}-koha-indexdefs.xml) > <xsl:call-template name="handle-index-heading"/> > <xsl:call-template name="handle-index-heading-conditional"/> > <xsl:call-template name="handle-index-match-heading"/> >+ <xsl:call-template name="handle-availability-index"/> > <xsl:apply-templates/> > <xslo:template mode="index_all" match="text()"> > <z:index name="Any:w Any:p"> >@@ -379,6 +381,24 @@ definition file (probably something like {biblio,authority}-koha-indexdefs.xml) > </xsl:for-each> > </xsl:template> > >+ <xsl:template name="handle-availability-index"> >+ <xsl:for-each select="//kohaidx:onloan_field"> >+ <xslo:template name="index_available"> >+ <z:index name="available:n"> >+ <xslo:value-of> >+ <xsl:attribute name="select"> >+ <xsl:text>count(marc:datafield[@tag='</xsl:text> >+ <xsl:value-of select="@tag"/> >+ <xsl:text>']/marc:subfield[@code='</xsl:text> >+ <xsl:value-of select="@subfield"/> >+ <xsl:text>' and not(contains(.,'1'))])</xsl:text> >+ </xsl:attribute> >+ </xslo:value-of> >+ </z:index> >+ </xslo:template> >+ </xsl:for-each> >+ </xsl:template> >+ > <xsl:template name="handle-one-data-field"> > <xsl:variable name="indexes"> > <xsl:call-template name="get-target-indexes"/> >-- >2.11.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 18098
:
60123
|
60818
|
60859
|
63112