Bug 15851 - Only display "Analytics: Show analytics" when records have linked analytics
Summary: Only display "Analytics: Show analytics" when records have linked analytics
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Cataloging (show other bugs)
Version: master
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Tomás Cohen Arazi
QA Contact: Katrin Fischer
URL:
Keywords:
Depends on: 26131
Blocks: 26314 26480 28513
  Show dependency treegraph
 
Reported: 2016-02-17 20:29 UTC by Ed Veal
Modified: 2021-08-06 11:00 UTC (History)
13 users (show)

See Also:
Change sponsored?: Sponsored
Patch complexity: Medium patch
Text to go in the release notes:
This development changes how the _Show analytics_ link is displayed in both OPAC and staff interface. The main changes are: * It is only displayed if it would actually have results (right now it always shows, and the link can point to empty results) * It is no longer constrained to serials: _collections_, _subunits_, _integrating resources_, _monographs_ and _serials_, all will display the link. New CSS classes are added for each material type: * _analytic_collection_ * _analytic_subunit_ * _analytic_ires_ * _analytic_monograph_ * _analytic_serial_ This way, libraries that wish to only display those links for serials (for example), can hide them for other resources: ``` .analytic_collection .analytic_subunit .analytic_ires .analytic_monograph { display: none }; ``` This CSS classes can be used in both OPAC and admin interface.
Version(s) released in:
20.11.00


Attachments
Bug 15851: Only display 'show analytics' link if there are (3.42 KB, patch)
2017-08-29 16:36 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 15851: Display analytics links for more cases (4.23 KB, patch)
2020-06-24 18:13 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 15851: Only display the analytics link when required (4.96 KB, patch)
2020-06-24 18:13 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 15851: Display analytics links for more cases (4.28 KB, patch)
2020-07-13 08:24 UTC, Hugo Agud
Details | Diff | Splinter Review
Bug 15851: Only display the analytics link when required (5.01 KB, patch)
2020-07-13 08:24 UTC, Hugo Agud
Details | Diff | Splinter Review
Bug 15851: Display analytics links for more cases (4.27 KB, patch)
2020-07-17 12:50 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 15851: Only display the analytics link when required (5.00 KB, patch)
2020-07-17 12:50 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 15851: (follow-up) Only display the analytics link when required (staff) (5.45 KB, patch)
2020-07-17 12:50 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 15851: Display analytics links for more cases (4.27 KB, patch)
2020-08-11 11:12 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 15851: Only display the analytics link when required (5.01 KB, patch)
2020-08-11 11:12 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 15851: (follow-up) Only display the analytics link when required (staff) (5.45 KB, patch)
2020-08-11 11:12 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 15851: Display analytics links for more cases (4.34 KB, patch)
2020-08-27 22:24 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 15851: Only display the analytics link when required (5.08 KB, patch)
2020-08-27 22:24 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 15851: (follow-up) Only display the analytics link when required (staff) (5.52 KB, patch)
2020-08-27 22:24 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 15851: Display analytics links for more cases (4.34 KB, patch)
2020-09-01 20:14 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 15851: Only display the analytics link when required (5.08 KB, patch)
2020-09-01 20:14 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 15851: (follow-up) Only display the analytics link when required (staff) (5.52 KB, patch)
2020-09-01 20:14 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 15851: (QA follow-up) Fix booleans to uppercase to make this work for Elasticsearch and UseControlNumber (1.64 KB, patch)
2020-09-01 20:14 UTC, Katrin Fischer
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Ed Veal 2016-02-17 20:29:37 UTC
All of records where position 7 of the leader indicates serial automatically display "Analytics: Show analytics" -- regardless of whether they have analytics. To confirm, we linked numerous items to host records in the case where monographic volumes were bound together via the "Link to Host Item" feature, automatically creating 773s. These are not in question and we do not want to make any changes that would affect them. The request is to remove the display "Analytics: Show analytics" for periodical records that do not have analytics.
Comment 1 Katrin Fischer 2016-02-17 20:45:47 UTC
There are 2 ways in Koha to manage analytical records - one is EasyAnalytics, which I think you are referring to. The other is using the "New child record" option and is based on the bibliographic record only, without involving the items. If you are using EasyAnalytics you could probably just hide the link with CSS as it should not be needed. 

The basic problem is, that the parent record doesn't know in the MARC if it has children... so we can't solve that only with XSLT, we need another way of checking for children.
Comment 2 Zeno Tajoli 2016-02-18 10:09:23 UTC
In unumarc is possible to use Leader pos. 8 [Hierarchical code].
The value '1' means 'highest level record', so it is sure it has children.
In MARC21 I think we need a proprietary subfield.
I suggest one from tag 942.
Comment 3 Katrin Fischer 2016-02-18 10:15:50 UTC
The 942 won't work in our use case for the same reason that we can't use EasyAnalatics. For libraries, where the bibliographic record is created outside of Koha and automatically kept in sync with the external master record, there is no way to have 'local' fields, because they will always be overwritten/deleted with an update.
Comment 4 Zeno Tajoli 2016-02-18 10:29:50 UTC
We can change the wording.
From "Analytics: Show analytics" to "Analytics: Search if present".
Comment 5 Hugo Agud 2017-08-18 08:35:53 UTC
We're doing a silly change in xslt in order to fix this

we use local marc tag to indicate koha that this record has analytics and then modifiy the xlst according to this.

There is two ways of fixing this.

1st --> manual one, using one tag to indicate koha that this record has analytics and show the link

2nd --> some kind of indexes that looks for 773$0 or 773$9 and activate it for the selected records
Comment 6 Hugo Agud 2017-08-18 08:55:21 UTC
3rd. move to the OPAC the current functionality that indicates that some items includes analytics like the intranet does .
Comment 7 Jonathan Druart 2017-08-29 16:36:51 UTC
Created attachment 66593 [details] [review]
Bug 15851: Only display 'show analytics' link if there are
Comment 8 Jonathan Druart 2017-08-29 16:39:37 UTC
As I am not sure to understand the need correctly, I have provided a quick (and dirty) patch. Let me know if it fixes the needs and I will improve it later if it is what you are waiting for.
Comment 9 Katrin Fischer 2017-08-29 16:45:19 UTC
Hi Jonathan, I don't see how the flag would be added, can you explain?

We have a lot of libraries with analytics which is why we added the featuer in the first place. The unsolved problem was and is that the MARC parent record doesn't know about it's children. And it's not easy to find out if there is one. If the library uses UseControlNumber for linking, you can check if the 001 of the parent appears in a 773$w with the rcn-Index. If the library doesn't link using numbers, you'd have to do a phrase search for 773$t(?) and Title.

A purely manual solution where you have to add a flag to the record would not work for us as we don't catlaog in Koha but in a cooperative catalouging environment (union catalog). So this should be optional then. 

Having a clean soluton that works without manual interference would be really nice as a lot of libraries have asked for the link to be smarter.
Comment 10 Jonathan Druart 2017-08-29 16:57:51 UTC
The flag ($analytics_flag) is set from detail.pl:289

286     #count if item is used in analytical bibliorecords
287     my $countanalytics= GetAnalyticsCount($item->{itemnumber});
288     if ($countanalytics > 0){
289         $analytics_flag=1;
290         $item->{countanalytics} = $countanalytics;
291     }
Comment 11 Katrin Fischer 2017-08-29 19:17:24 UTC
It looks like this could work for EasyAnalytics - but it would break the workflow for people using UseControlNumber - linking without any items involved on bibliographic record level (MARC21 standard)
Comment 12 Zeno Tajoli 2017-08-30 08:31:57 UTC
Hi,

in fact Katrin underline the problematic point: in MARC21 standard catalouging nothing in parent biblio record of a serial  says if it has analitics.
Probably a good option is:
1)A new Sys pref "AnaliticsWithControlNumbers" and say: "Set it 'ON' only if you use control numbers in 77x$w and don't use  EasyAnalytics".
2)A new function like "GetAnalyticsCount" but based on controlnumber and rcn-Index.
Comment 13 Hugo Agud 2017-08-30 08:57:03 UTC
At the what we need is to know if a bib record has analytics, we do not need silly xslt links based on bib-leve:s (journals) and on the other hand we have forgotten about chapters not only serial (bib-level:b)

The link between bib and analytics is 773 field... here the big issue is most of fields are text 773$t and the one to one link are 773$0 773$9 or even 773$x(issn (journals) or 773$w(controlnumber) depends on every library, how they have created the analytics...they will have more or less filled tags

If you're using koha and have created the analytics with koha you will have a nice 773 to work create links ;)

Now in the staff cients, in the analytics tab you have info about if that item has anaytics attached and how many... because the 773$9 (one to one link and it works fine)

I think there is not a 100% solution, because there will be plenty of different situations and one solution won't match all possible situations

I like the idea of the syspref 'GetAnalyticsCount' but we must be clear enought with the customers explaining how the links works

The idea it should be, that the library must  check their current 773 tags and fix it. (they have a nice batch record modification tool)

There is 3 potential ways:
for current biblionumber --> appear the link if there is any 773$0 that matchs the biblio
or

for current itemnumbers --> appear a link if there is any 773$9 that matchs the itemnumber

or
for current issn --> apprear a link if there is any 773$x that matches 022$a

I don not like the control-number:
the use of control number I dislike because koha is not using 001 control-number
Comment 14 Katrin Fischer 2017-08-30 09:34:08 UTC
(In reply to Hugo Agud from comment #13)
> At the what we need is to know if a bib record has analytics, we do not need
> silly xslt links based on bib-leve:s (journals) and on the other hand we
> have forgotten about chapters not only serial (bib-level:b)

The links have been created so you can hide them very easily with CSS if you don't want or need them.

> The link between bib and analytics is 773 field... here the big issue is
> most of fields are text 773$t and the one to one link are 773$0 773$9 or
> even 773$x(issn (journals) or 773$w(controlnumber) depends on every library,
> how they have created the analytics...they will have more or less filled tags
> 
> If you're using koha and have created the analytics with koha you will have
> a nice 773 to work create links ;)

Not all libraries catalog solely in Koha. But: you can create analytics within Koha in 2 different ways already. One is EasyAnalytics which is tied to the items, the other is from the detail view available as well and supports Controlnumber linking: New > New child record. If a 001 exists, it will be used.

The different linking methods/options are the reson that there is a fallback from $w to a Title search. More logic could be added there to include other possible good search parameters like ISBN/ISSN.

> Now in the staff cients, in the analytics tab you have info about if that
> item has anaytics attached and how many... because the 773$9 (one to one
> link and it works fine)

Please keep in mind that this is only available for libraries using EasyAnalytics.

> I think there is not a 100% solution, because there will be plenty of
> different situations and one solution won't match all possible situations
> 
> I like the idea of the syspref 'GetAnalyticsCount' but we must be clear
> enought with the customers explaining how the links works
> 
> The idea it should be, that the library must  check their current 773 tags
> and fix it. (they have a nice batch record modification tool)

> 
> There is 3 potential ways:
> for current biblionumber --> appear the link if there is any 773$0 that
> matchs the biblio
> or

There is no $0 defined for 773 in MARC standard?

> 
> for current itemnumbers --> appear a link if there is any 773$9 that matchs
> the itemnumber
> 
> or
> for current issn --> apprear a link if there is any 773$x that matches 022$a

Please don't forget $w here - it's actually one of the best possible links, as the matching should be exact based on ID.


> I don not like the control-number:
> the use of control number I dislike because koha is not using 001
> control-number

Please keep other workflows in mind. Our records are linked outside of Koha by ID in an external cataloguing environment, everything is held together by 001. One central cataloguing environment, data delivered to lots of different ILS. Also: 001/$w IS MARC standard.
Comment 15 Joy Nelson 2018-02-01 21:59:07 UTC
Cait-
I can appreciate that your libraries have workflows related to analytics here.  However, the vast majority of other libraries using MARC21 standard do not intend the Leader position 7 to indicate that there are analytics present.  I believe that Koha should be displaying the bibliographic data in a way that is accurate to the data that is entered.  In this case not display an analytic tag just because leader position 7 =s.  

I have a number of libraries who would love to see this 'feature' removed and have Koha catalog and display in the correct fashion (according to marc21 standards).

joy
Comment 16 Katrin Fischer 2018-02-01 22:15:30 UTC
(In reply to Joy Nelson from comment #15)
> Cait-
> I can appreciate that your libraries have workflows related to analytics
> here.  However, the vast majority of other libraries using MARC21 standard
> do not intend the Leader position 7 to indicate that there are analytics
> present.  I believe that Koha should be displaying the bibliographic data in
> a way that is accurate to the data that is entered.  In this case not
> display an analytic tag just because leader position 7 =s.  
> 
> I have a number of libraries who would love to see this 'feature' removed
> and have Koha catalog and display in the correct fashion (according to
> marc21 standards).
> 
> joy

I am not sure how to hide it by default and make it display on demand. At the moment you can hide it with one line of CSS. Would hiding it in the default CSS and unhiding in OpacUserCSS work?

We also hide it for a lot of libraries as most don't have analytics - and then they don't have analytics on all records. I just wanted to say: don't kill it by assuming everyone uses EasyAnalytics. I am open to suggestions on how to make this work better - Ideally it should only display when there are linked records.
Comment 17 Joy Nelson 2018-02-01 23:31:05 UTC
Cait-
I agree that this could be a responsive feature in Koha.  However, to most librarians it appears that Koha is 'doing something' (displaying analytic links) that is not supported by the correct cataloging of records.  Catalogers put a lot of effort into correctly cataloging their collections.  And when this cataloging results in behavior that is not related to the industry standards, it causes frustration, confusion and some lack of confidence in the tool.  

Yes, it could be hidden, but by doing so we are expecting the bulk of Marc21 libraries to hide something that should never be there in the first place.
Comment 18 Katrin Fischer 2018-02-02 06:15:37 UTC
Joy, I understand. Let's try to figure out something that works for us both. What about my suggestion to turn the CSS around from the last comment? (hide by default, make it possible to unhide)
Comment 19 Katrin Fischer 2018-02-02 06:23:29 UTC
I'd be happiest with a solution where we fixed the idea from Jonathan so that it works for both use cases - EasyAnalytics and simple 773 linking. Looking at the patch it seems to be missing the code to actually calculate the $analytics_flag?

I think we could all agree that this would be a nice enhancement, showing a link only when there are analytics. Or just never show a link if EasyAnalytics is used?

I am just not sure how to do it, which is the whole reason it was not implemented like that from the beginning :( With some guidance I would be happy to give it a try.
Comment 20 Marcel de Rooy 2018-02-02 06:43:10 UTC
(In reply to Joy Nelson from comment #17)
> Cait-
> I agree that this could be a responsive feature in Koha.  However, to most
> librarians it appears that Koha is 'doing something' (displaying analytic
> links) that is not supported by the correct cataloging of records. 
> Catalogers put a lot of effort into correctly cataloging their collections. 
> And when this cataloging results in behavior that is not related to the
> industry standards, it causes frustration, confusion and some lack of
> confidence in the tool.  
> 
> Yes, it could be hidden, but by doing so we are expecting the bulk of Marc21
> libraries to hide something that should never be there in the first place.

Sounds reasonable to me. 'Can you hide it' should not be the approach imo..
Comment 21 Katrin Fischer 2018-02-02 06:48:26 UTC
Can we all start working on a solution instead of chiming in that a feature added 2006 is bad? ;)
Comment 22 Katrin Fischer 2018-02-02 06:49:43 UTC
Sorry, 2011.
Comment 23 Brian 2018-12-18 01:42:56 UTC
Has any more progress been made on Bug 15851?

Carnegie Staff
Comment 24 Joy Nelson 2018-12-26 17:52:39 UTC
Katrin,
Currently this analytic feature only works where the leader7=s.  I'd like to propose the following changes to this feature to allow it be used by your library and others in a more standard method.

1. Allow the link to appear when leader7 =s or leader7=m.  Both monographs and serial records can have component parts and as such have children that should be displayed by this feature.  The Show analytics link is searching for bib-level:a (Monographic component part) and bib-level:b (Serial component part).

2. Add a search function to this display page that checks the index (Host-item) to see if any children are present. If so, then display the "Show Analytics Link".  This search would search for control number or title depending on the value of usecontrolnumber sys pref.  

3. Add a syspref for this method of analytic cataloging, much like we have for Easy Analytics and 'use control number'.  Allow libraries the ability to turn off the analytic cataloging if they don't use it.  Call it "ShowLinktoChildfromParent"?  

Your thoughts?
joy
Comment 25 Katrin Fischer 2019-02-27 06:49:11 UTC
Hi Joy, 

sorry, I missed getting back to this :(

(In reply to Joy Nelson from comment #24)
> Katrin,
> Currently this analytic feature only works where the leader7=s.  I'd like to
> propose the following changes to this feature to allow it be used by your
> library and others in a more standard method.
> 
> 1. Allow the link to appear when leader7 =s or leader7=m.  Both monographs
> and serial records can have component parts and as such have children that
> should be displayed by this feature.  The Show analytics link is searching
> for bib-level:a (Monographic component part) and bib-level:b (Serial
> component part).

Yes, that makes sense. Actually we have that link in some custom XSLT, but use a different class to allow changing visibility independently for m and s.

> 
> 2. Add a search function to this display page that checks the index
> (Host-item) to see if any children are present. If so, then display the
> "Show Analytics Link".  This search would search for control number or title
> depending on the value of usecontrolnumber sys pref.  

I would be totally ok with that. I just never figured out how to do this myself. Some help here would be great. I am not sure Host-item will work as an index or if a new index for $w in 773 would be needed for the controlnumber part.

> 3. Add a syspref for this method of analytic cataloging, much like we have
> for Easy Analytics and 'use control number'.  Allow libraries the ability to
> turn off the analytic cataloging if they don't use it.  Call it
> "ShowLinktoChildfromParent"?  

I am not sure about adding more and more prefs when CSS would work, but if we add the function in 2) it makes sense to have a real switch to avoid unnecessary processing.

I had some hope that [Bug 11175] Show the parent record's component parts in the detailed views would help resolve the issues or replace the current way, but it hasn't worked out.
Comment 26 Hugo Agud 2019-10-23 09:43:11 UTC
Sponsor propousal

We need a solution for show links to analaytics only if there are analytics and not just at journal level, there is also book chapter as analytics.

CASE 1.

If analytics are created via koha, we have all 773 fields filled and we can apply the used in as it is in staff gui

CASE 2
If the analytics have been propertly created using

773$w <--check match 773w vs 001-->
773$x <-- check match 773x vs 020 and 022-->

I know that some records came from other catalogues, but if they do not fill 773$w or 773$x they're not marc21 and then they do not desserve havings show analytics publishing ;)

If this is the case then they just need use batch record modification to improve the quality of their records.

I suggest the creation of cronjob with options how to check if there are analyrtics


count_analytics --match w --match 0 --match 9 --match x (the cron will check all 77309wx and compare with 001, 020, 022, 999c and 9520 and if there is a match add a counter at the record (this records has 9 analytics) and publish on the bib level for example.
Comment 27 Katrin Fischer 2020-05-03 23:21:35 UTC
Trying to summarize and epxlain... sorry it got long:

I think we need to be careful here in general as we have multiple ways of handling analytics in Koha right now, that cannot be mixed (afaik). The best write-up about this we have is: 

  https://wiki.koha-community.org/wiki/Multipart_Bibliographics

1) Links between records using $w (7xx $w => 001)

The links here are only on record level. There is no effect on item visibility.

2) Links between records and items using EasyAnalytics feature (773 => $9 $0 $w)

$0 = biblionumber of parent record
§9 = itemnumber of parent item
$w = (003)001 of parent record 

The links here involve records and items. One existing physical item can be displayed on multiple records. This makes it really interesting for bound items. I've not been able to use this feature in our union catalog setting as it adds 773 entries to the records and we'd kill them with our regular updates :(

--

Joubu's attached patch suggests using the analytics_flag, but this will only give results for 2) and never display the link for libraries using 1). You can also see here, that it relies on an itemnumber. The link here is more between a host item and related records, than between records.

opac-detail.pl:
my $countanalytics = C4::Context->preference('EasyAnalyticalRecords') ? GetAnalyticsCount($item->{itemnumber}) : 0;
if ($countanalytics > 0){
  $analytics_flag=1;
  $item->{countanalytics} = $countanalytics;
}

Maybe we could improve Joubu's patch by also checking the EasyAnalyticalRecords pref - then it could work for case 2). To my knowledge there were issues using 1) and 2) together - maybe libraries can tell if that's still the case (or testing could). The wiki lists UseControlNumbers and EasyAnalyticalRecords as mutually exclusive.

What Hugo suggests could work, if I understand correctly, it would do about this:

- Find all records with 773
- Look for matching linked records using the available standard identifiers:
  - If EasyAnalyticalrecords is used:
    - $9 = biblionumber
    - $0 = itemnumber
  - Also:
    - $w = 001 Control number
    - $x = 020 ISBN
    - $z = 022 ISSN

Deduplicate bilbionumbers and add their count (or maybe the full relationship information? 773, host biblionumber, linked biblionumber) to a table.

Then we could look up that information and push it to the XML like Joubus patch does with the flag. Even more: We could show the exact number of linked records.

I'd like to make following suggestions:

- Use a separate table for storing information about record relationships (count of records linked)
- Make it generic enough it could be expanded for other relationships beyond 773 (volumes in a set, volumnes in a series.. etc.) 
- Have a way to update the counter when adding/deleting/editing a record in the GUI. People might get irritated if the link doesn't show when saving their records.
- Give the script the option to run incrementally, either for all records stored in a database (starting out) or only looking at records added or changed since x. ago. It could be too 'expensive' to fully run it on a big database over and over.
Comment 28 Hugo Agud 2020-05-04 06:50:30 UTC
100% agree katrin, perfect summary!

However I have been thinking on it and I suggest to go one step further,  add to the scrip the chance of filling 001 with 999$c

In some migrated libraries they came to koha using type2 (773w-->001), the issue  is that 001 is mandatory for linking and at koha is empty by default, I suggest to add an option to the script to copy 999c to 001 and helps librarian to create anañytics using 773$w--001
Comment 29 Katrin Fischer 2020-05-04 07:03:29 UTC
If you add multiple mappings, there is a risk of creating false links.

$w = 001 or 999$c 

$w is actually a 001 value, but the same value exists as biblionumber.
or
$w is a biblionumber, but there also exists a 001 with the value.
Comment 30 Hugo Agud 2020-05-04 07:11:14 UTC
At the end what we wish display the link propertly .... the only issue (it is big) it could came with counter, not with the link.

I mean if we have one bib record and one analytic with all fields filled (773W0 --> 001 + 773$0 or even 773$9)

The worth scenario is couning two times, but even then we have a valid link with but wrong count number... ok, 100% agree but evern is better to have no links ;)

On the other hand it is just a matter of dedup linking I mean, host bib couldn't link to same bib analyic record more than one...then if the count take care of that, issue fixed

Almost all migrsted libraries have analytics using 773$w and 773$0, and perhpas some of them will migrate from 773w to 7730 because is stronger and better as you can add analytics to issue level, if we manage that, the solution is stronger
Comment 31 Katrin Fischer 2020-05-05 20:59:19 UTC
Using $0 is non standard and not an option for all libraries as not all libraries maintain their records locally in Koha. It's good to keep different use cases in mind. 

If the script was adding biblionumber to 001, I guess it would not matter as much: 001 = 999$c so $w = $0?
Comment 32 Tomás Cohen Arazi 2020-05-13 12:52:45 UTC
I've started thinking on a solution to this, due to my recent works on XSLTs and plugins. I'll keep you posted.
Comment 33 Tomás Cohen Arazi 2020-05-26 22:08:04 UTC
Truth is catalogues need to be assumed heterogeneous, and that's starting point on any solution to this:
- Advanced analytics
- EasyAnalytics
- Hand-made 773 fields (and whatever happens in UNIMARC)+

They can all happen in the same catalog (importing external records, different geological eras on the biblio database, etc)

I see two options:
1) Implement the same logic of searching linked records that is used on creating the link, but on the *detail.pl files. This would be similar to Jonathan's approach, but it would consider more use cases. Pros: the implementation is very simple and straight-forward, if it works on the XSLT we could consider it valid on the .pl and we could just pass the variable to the XSLT for proper rendering, independent on the leader value. Cons: It is not exactly correct (if we assume the catalog is heterogeneous, then some research needs to be done on those searches, maybe there should be a search for both use cases in a single query, but also the one Jonathan used (for the EasyAnalytics case). This would certainly add latency on rendering a record.

2) Add a 'has_child_biblios' boolean column, and introduce sysprefs to control what strategies to use for finding children records. This could be hooked on saving records, and have an on/off switch. This way we would have something like:

- BibliosKeepChildrenInfo (on/off switch)
- BibliosKeepChildrenStrategy: controlnumber|easyanalytics|freesearch

BibliosKeepChildrenStrategy should be sortable and you should be able to choose which options to use.

A maintenance script should be added for populating this boolean the first time.
The current XSLT behaviour could be kept with a deprecation notice, but I think the constraint to do it only for serials is wrong (a bug).
Comment 34 Katrin Fischer 2020-05-26 22:19:50 UTC
I understand the disagreement, but we have added lots of other information on the base that it can be hidden with CSS if unwanted - serials are more likely to have analytics than monographs, so that's why the limit was introduced in the first place. In our own XSLT we also have a version for monographs (same but different class) and control both of them with CSS. But I know our libraries would love it too to only see it when there actually are child records.

I am not sure I understand how 1) would look like, can you explain a bit more?

With 2) we also need to account for every way a record can be added or edited in Koha - including the imports.
Comment 35 Tomás Cohen Arazi 2020-05-26 22:44:39 UTC
(In reply to Katrin Fischer from comment #34)
> I understand the disagreement, but we have added lots of other information
> on the base that it can be hidden with CSS if unwanted - serials are more
> likely to have analytics than monographs, so that's why the limit was
> introduced in the first place. In our own XSLT we also have a version for
> monographs (same but different class) and control both of them with CSS. But
> I know our libraries would love it too to only see it when there actually
> are child records.

I don't see a disagreement yet. I'm pondering options. My idea is that we could add different classes for each leader value (if you require that) and even hide them all by default to keep the current behaviour. No proposal from me will break your workflow, Katrina.

> I am not sure I understand how 1) would look like, can you explain a bit
> more?

Jonathan's code uses a method to search for EasyAnalytics related biblios. We need to have that AND a Zebra/Elasticsearch query for Host-item and rcn. If any of those returns something, then there's analytics and something similar-ish to Jonathan's approach can be used. I will produce a patch for this option tomorrow (my) morning so we check how bad it is for performance.

> With 2) we also need to account for every way a record can be added or
> edited in Koha - including the imports.

Yes, they all ultimately call ModBiblio so I'm not *that* worried about it.

So the struggle here is: fix the data? assume heterogeneous database?
Comment 36 Tomás Cohen Arazi 2020-06-24 18:13:36 UTC
Created attachment 106260 [details] [review]
Bug 15851: Display analytics links for more cases

The current XSLT displays the link to linked analytics only for serials.
This patch makes it show for all the relevant position 7 on the leader
values. I left out a and b as recommended by expert librarians on my
team, but I can revert that if required.

The current implementation adds a new CSS class for each case, so
libraries willing to keep the current behaviour or just have more
granular control on the cases they want the link to display, just can.

This patch makes sense with the follow-up one, which will display the
link only if there are really related records.

To test:
1. Open a non-serial record, notice there's no link to analytics
2. Apply this patch and reload
=> SUCCESS: There's an 'Analytics' link
3. Inspect the produced HTML
=> SUCCESS: A special class with analytic_* value has been added, and
thus we now can control its display through CSS
4. Sign off :-D

Sponsored-by: Orex Digital
Comment 37 Tomás Cohen Arazi 2020-06-24 18:13:42 UTC
Created attachment 106261 [details] [review]
Bug 15851: Only display the analytics link when required

This patch makes opac-detail.pl query for analytics the same way it
would do with the generated link (i.e. based on UseControlNumber) and
passes a flag to the XSLT so it displays (or not) the 'Analytics' link.

To test:
1. Apply the first patch
2. Have a known record without analytics
3. Open the record in the OPAC
=> FAIL: It shows the 'Analytics' link
4. Have a record known to have analytics and open in OPAC, on a separate
   tab
=> SUCCESS: It shows the 'Analytics' link
5. Apply this patch and restart_all
6. Reload the tabs
=> SUCCESS: It shows the link where it has to, and hides it where it
shouldn't be displayed
7. Sign off :-D

Sponsored-by: Orex Digital
Comment 38 Tomás Cohen Arazi 2020-06-25 14:05:06 UTC
Ok, this is my attempt. The basic idea is split in two:
- Display analytic links for more cases (i.e. not just serial)
- If the result for showing the link is considered (today) good enough, just use the same query in the code to make the decision on the .pl+XSLT combination

If this approach to 'hiding when unnecessary' is good enough (I think it is) we could file a new but for adding new conditions (like ISBN, etc).

Feedback welcome!
Comment 39 Hugo Agud 2020-07-09 09:44:31 UTC
I hae tested the patch and it works fine! however the code applied to opac is not applied to staff xslt and it shows the links always, even when there is not analytics.
Comment 40 Tomás Cohen Arazi 2020-07-09 14:43:07 UTC
(In reply to Hugo Agud from comment #39)
> I hae tested the patch and it works fine! however the code applied to opac
> is not applied to staff xslt and it shows the links always, even when there
> is not analytics.

My idea was to have feedback on the approach, and then move to other areas. The 'how to find analytics' discussion (i.e. the queries that are done) should be moved to another bug, for example.

Thanks for testing, and I will add the intranet counterpart for you to SO ASAP.
Comment 41 Hugo Agud 2020-07-13 08:24:42 UTC
Created attachment 106821 [details] [review]
Bug 15851: Display analytics links for more cases

The current XSLT displays the link to linked analytics only for serials.
This patch makes it show for all the relevant position 7 on the leader
values. I left out a and b as recommended by expert librarians on my
team, but I can revert that if required.

The current implementation adds a new CSS class for each case, so
libraries willing to keep the current behaviour or just have more
granular control on the cases they want the link to display, just can.

This patch makes sense with the follow-up one, which will display the
link only if there are really related records.

To test:
1. Open a non-serial record, notice there's no link to analytics
2. Apply this patch and reload
=> SUCCESS: There's an 'Analytics' link
3. Inspect the produced HTML
=> SUCCESS: A special class with analytic_* value has been added, and
thus we now can control its display through CSS
4. Sign off :-D

Sponsored-by: Orex Digital

Signed-off-by: Hugo Agud <hagud@orex.es>
Comment 42 Hugo Agud 2020-07-13 08:24:46 UTC
Created attachment 106822 [details] [review]
Bug 15851: Only display the analytics link when required

This patch makes opac-detail.pl query for analytics the same way it
would do with the generated link (i.e. based on UseControlNumber) and
passes a flag to the XSLT so it displays (or not) the 'Analytics' link.

To test:
1. Apply the first patch
2. Have a known record without analytics
3. Open the record in the OPAC
=> FAIL: It shows the 'Analytics' link
4. Have a record known to have analytics and open in OPAC, on a separate
   tab
=> SUCCESS: It shows the 'Analytics' link
5. Apply this patch and restart_all
6. Reload the tabs
=> SUCCESS: It shows the link where it has to, and hides it where it
shouldn't be displayed
7. Sign off :-D

Sponsored-by: Orex Digital

Signed-off-by: Your Full Name <your_email>
Comment 43 Tomás Cohen Arazi 2020-07-17 12:50:27 UTC
Created attachment 106988 [details] [review]
Bug 15851: Display analytics links for more cases

The current XSLT displays the link to linked analytics only for serials.
This patch makes it show for all the relevant position 7 on the leader
values. I left out a and b as recommended by expert librarians on my
team, but I can revert that if required.

The current implementation adds a new CSS class for each case, so
libraries willing to keep the current behaviour or just have more
granular control on the cases they want the link to display, just can.

This patch makes sense with the follow-up one, which will display the
link only if there are really related records.

To test:
1. Open a non-serial record, notice there's no link to analytics
2. Apply this patch and reload
=> SUCCESS: There's an 'Analytics' link
3. Inspect the produced HTML
=> SUCCESS: A special class with analytic_* value has been added, and
thus we now can control its display through CSS
4. Sign off :-D

Sponsored-by: Orex Digital

Signed-off-by: Hugo Agud <hagud@orex.es>
Comment 44 Tomás Cohen Arazi 2020-07-17 12:50:32 UTC
Created attachment 106989 [details] [review]
Bug 15851: Only display the analytics link when required

This patch makes opac-detail.pl query for analytics the same way it
would do with the generated link (i.e. based on UseControlNumber) and
passes a flag to the XSLT so it displays (or not) the 'Analytics' link.

To test:
1. Apply the first patch
2. Have a known record without analytics
3. Open the record in the OPAC
=> FAIL: It shows the 'Analytics' link
4. Have a record known to have analytics and open in OPAC, on a separate
   tab
=> SUCCESS: It shows the 'Analytics' link
5. Apply this patch and restart_all
6. Reload the tabs
=> SUCCESS: It shows the link where it has to, and hides it where it
shouldn't be displayed
7. Sign off :-D

Sponsored-by: Orex Digital

Signed-off-by: Hugo Agud <hagud@orex.es>
Comment 45 Tomás Cohen Arazi 2020-07-17 12:50:37 UTC
Created attachment 106990 [details] [review]
Bug 15851: (follow-up) Only display the analytics link when required (staff)

This patch replicates the introduced behaviour, for the admin interface.
To test, follow the test plan from the OPAC, but on the intranet.

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 46 David Cook 2020-07-22 05:49:19 UTC
I was wondering what kind of performance impacts this would have on a large database with lots of analytics, but a code review shows that it looks good enough (depending on your views).

Looking at C4::Search::SimpleSearch, we're passing an offset of 0 and max_results of 0, which generates a range of 1..0 which is nothing, so no records are actually fetched from Zebra. 

It's not very elegant, but it should be functional, even for a large database. 

I tested an unrelated search using yaz-client on a very large database (over 1 million bib records), and for a query with 17626 hits, it took .432 seconds. 

For some people, adding .432 seconds to web page load time is unacceptable, but I imagine most of us might not care too much.

I'd argue that this lookup should be performed asynchronously after the HTML page has loaded.

The MARC data could trigger whether to show an "Analytics" label I suppose, and then the result of the async lookup would say something like "Show Analytics" or "None" or something like that. 

Anyway, that's just a thought. I'm not interested in doing any work on this. I'm just always interested in performance. 

The current patches are fine, so I'm not being critical, but I think an optimization would be to do an async lookup.
Comment 47 Tomás Cohen Arazi 2020-07-27 20:35:48 UTC
(In reply to David Cook from comment #46)
> I was wondering what kind of performance impacts this would have on a large
> database with lots of analytics, but a code review shows that it looks good
> enough (depending on your views).
> 
> Looking at C4::Search::SimpleSearch, we're passing an offset of 0 and
> max_results of 0, which generates a range of 1..0 which is nothing, so no
> records are actually fetched from Zebra. 
> 
> It's not very elegant, but it should be functional, even for a large
> database.

I take it as a compliment-ish comment, thanks :-P
 
> I tested an unrelated search using yaz-client on a very large database (over
> 1 million bib records), and for a query with 17626 hits, it took .432
> seconds. 

Can you give me the query so I can try on my databases as well?

> For some people, adding .432 seconds to web page load time is unacceptable,
> but I imagine most of us might not care too much.

I'd agree. We could make it an opt-in feature? PreciseAnalyticsLink or smth.

> I'd argue that this lookup should be performed asynchronously after the HTML
> page has loaded.
> 
> The MARC data could trigger whether to show an "Analytics" label I suppose,
> and then the result of the async lookup would say something like "Show
> Analytics" or "None" or something like that. 
> 
> Anyway, that's just a thought. I'm not interested in doing any work on this.
> I'm just always interested in performance. 
> 
> The current patches are fine, so I'm not being critical, but I think an
> optimization would be to do an async lookup.

I like the idea. Will draft an endpoint for fetching such information using the exact queries we use here.
Comment 48 David Cook 2020-07-29 01:34:15 UTC
(In reply to Tomás Cohen Arazi from comment #47)
> I take it as a compliment-ish comment, thanks :-P
>

I'm sure that you know that I think the world of you, Tomás <3. Heh.

> Can you give me the query so I can try on my databases as well?
> 

Actually, now that I look at it, I gave it a bad query. I tried "local-number=1000" thinking I had it set up for CCL2RPN, but it actually tried that as a PQF query. It got 0 hits, but it searched it as "local and number and 1000" with subquery results of 250,000, 125,000 and 20,000 respectively in 0.435 seconds.

I just tried searching "the" and it took 5.16 seconds to return a result with 1,125,000 hits.

I just tried "local" and got 250,000 hits in 0.193 seconds. 

Note that this is all using yaz-client and a unix socket (rather than a TCP socket).

I wonder if doing a CCL2RPN conversion adds much overhead... I'll try that and add another separate comment, as this one is growing too large.

> > For some people, adding .432 seconds to web page load time is unacceptable,
> > but I imagine most of us might not care too much.
> 
> I'd agree. We could make it an opt-in feature? PreciseAnalyticsLink or smth.
> 
> > I'd argue that this lookup should be performed asynchronously after the HTML
> > page has loaded.
> > 
> > The MARC data could trigger whether to show an "Analytics" label I suppose,
> > and then the result of the async lookup would say something like "Show
> > Analytics" or "None" or something like that. 
> > 
> > Anyway, that's just a thought. I'm not interested in doing any work on this.
> > I'm just always interested in performance. 
> > 
> > The current patches are fine, so I'm not being critical, but I think an
> > optimization would be to do an async lookup.
> 
> I like the idea. Will draft an endpoint for fetching such information using
> the exact queries we use here.

If we're doing it async, I don't think we'd need it to be an opt-in feature, as it would already be optimized. 

And thanks for drafting that!
Comment 49 David Cook 2020-07-29 01:59:10 UTC
Ok using .yazclientrc to set the following:

1. querytype ccl2rpn
2. set_cclfile /path/to/etc/zebradb/ccl.properties

Trying the following:

1. Host-item="This is a test"
2. rcn=1000 and (bib-level=a or bib-level=b)

Both of these returned results in 0.002 seconds with 0 hits.

The search performance is interesting.

Going back to these:

1. "find e" 
2. "find the"

They're both using the "Any:w" index, but "e" takes .09 seconds to return 37500 hits while "the" takes 3.39 seconds to return 1125000 hits.

Zebra has to take the same amount of time to scan the index, so the time spent in yaz-client isn't on Zebra finding the data. It's spent on either Zebra/yaz-client/both processing the data.

The time taken seems to be linear/O(n) not for searching per se but rather in terms of returning a search result. 

Now it's just unclear whether it's Zebra or yaz-client (or both) causing the time delay. 

I might try writing a quick little Perl script to see how it fairs when using Zoom with Zebra...
Comment 50 David Cook 2020-07-29 02:14:46 UTC
yaz-client: local-number=10000
1 hit
0.002227 seconds

Koha code*: local-number=10000
1 hit
2.093 seconds

At this point, it's worth noting that approximately 2 seconds is spent just loading Modern::Perl, C4::Context, and C4::Search, so it's not a fair comparison.

I'm going to do another comparison using "e" and "the"... 


*
#!/usr/bin/perl
use Modern::Perl;
use C4::Context;
use C4::Search;
my @tmpresults;
my @zconns;
$zconns[0] = C4::Context->Zconn( 'biblioserver', 1 );
my $query = "Host-Item=this is a test";
$query = "local-number=10000";
my $zoom_query = new ZOOM::Query::CCL2RPN($query, $zconns[0]);
$tmpresults[0] = $zconns[0]->search($zoom_query);
my $total_hits = 0;
C4::Search::_ZOOM_event_loop(
        \@zconns,
        \@tmpresults,
        sub {
                my ($i,$size) = @_;
                $total_hits += $tmpresults[$i - 1] ->size();

        },
);
warn $total_hits;
Comment 51 Tomás Cohen Arazi 2020-07-29 02:31:05 UTC
(In reply to David Cook from comment #49)
> Ok using .yazclientrc to set the following:
> 
> 1. querytype ccl2rpn
> 2. set_cclfile /path/to/etc/zebradb/ccl.properties
> 
> Trying the following:
> 
> 1. Host-item="This is a test"
> 2. rcn=1000 and (bib-level=a or bib-level=b)
> 
> Both of these returned results in 0.002 seconds with 0 hits.
> 
> The search performance is interesting.
> 
> Going back to these:
> 
> 1. "find e" 
> 2. "find the"
> 
> They're both using the "Any:w" index, but "e" takes .09 seconds to return
> 37500 hits while "the" takes 3.39 seconds to return 1125000 hits.
> 
> Zebra has to take the same amount of time to scan the index, so the time
> spent in yaz-client isn't on Zebra finding the data. It's spent on either
> Zebra/yaz-client/both processing the data.
> 
> The time taken seems to be linear/O(n) not for searching per se but rather
> in terms of returning a search result. 
> 
> Now it's just unclear whether it's Zebra or yaz-client (or both) causing the
> time delay. 
> 
> I might try writing a quick little Perl script to see how it fairs when
> using Zoom with Zebra...

Can you try zoomsh? Is what IndexData recommends.
Comment 52 Tomás Cohen Arazi 2020-07-29 02:31:52 UTC
(In reply to Tomás Cohen Arazi from comment #51)
> (In reply to David Cook from comment #49)
> > Ok using .yazclientrc to set the following:
> > 
> > 1. querytype ccl2rpn
> > 2. set_cclfile /path/to/etc/zebradb/ccl.properties
> > 
> > Trying the following:
> > 
> > 1. Host-item="This is a test"
> > 2. rcn=1000 and (bib-level=a or bib-level=b)
> > 
> > Both of these returned results in 0.002 seconds with 0 hits.
> > 
> > The search performance is interesting.
> > 
> > Going back to these:
> > 
> > 1. "find e" 
> > 2. "find the"
> > 
> > They're both using the "Any:w" index, but "e" takes .09 seconds to return
> > 37500 hits while "the" takes 3.39 seconds to return 1125000 hits.
> > 
> > Zebra has to take the same amount of time to scan the index, so the time
> > spent in yaz-client isn't on Zebra finding the data. It's spent on either
> > Zebra/yaz-client/both processing the data.
> > 
> > The time taken seems to be linear/O(n) not for searching per se but rather
> > in terms of returning a search result. 
> > 
> > Now it's just unclear whether it's Zebra or yaz-client (or both) causing the
> > time delay. 
> > 
> > I might try writing a quick little Perl script to see how it fairs when
> > using Zoom with Zebra...
> 
> Can you try zoomsh? Is what IndexData recommends.

And also the plain PQF query while you're on it
Comment 53 David Cook 2020-07-29 02:45:22 UTC
yaz-client: e
37500 hits
.09 seconds

Koha: e
37500 hits
2.110 seconds (2 seconds being loading Perl modules, so .110 sec)

yaz-client: the
1125000 hits
3.39 seconds

Koha: the
1125000 hits
5.315 seconds (2 seconds being loading Perl modules, so 3.315 sec)

If we convert from async code to sync code, we can get the following:
1125000 hits
3.78 seconds (2 seconds being loading Perl modules, so 1.78 sec)

If we comment out the code after the search(), we can see that it still takes 3.7-4 seconds to run, so the time delay appears to be on the Zebra side. I see high CPU usage but not high memory usage, so it looks like it's processing something. Of course, Zebra is a bit of a black box for us. 

For a Plack enabled Koha, my guess is that this search should have a minimal impact, unless a bib record has hundreds of thousands/millions of articles referencing it. 

The highest hit is probably going to be < 100, and since the time is dependent on the size of the search result rather than the size of the index, database size should be irrelevant. 

The biggest impact in terms of performance will probably be loading Perl modules via "use Koha::SearchEngine::Search". For Plack, this will be a once off for a worker that hasn't loaded opac-detail.pl before. For CGI, it could add 1-2 seconds of latency each time opac-detail.pl is loaded.
Comment 54 David Cook 2020-07-29 02:45:58 UTC
(In reply to Tomás Cohen Arazi from comment #51)
> Can you try zoomsh? Is what IndexData recommends.

I'd never heard of that. Very cool.
Comment 55 David Cook 2020-07-29 02:46:25 UTC
(In reply to Tomás Cohen Arazi from comment #52)
> And also the plain PQF query while you're on it

So the "e" and "the" queries are plain PQF queries.
Comment 56 David Cook 2020-07-29 02:47:54 UTC
So it looks like Zebra response times increase as the number of hits increased (even without fetching records).

And loading C4::Search takes 1-2 seconds.

Ultimately, this is unlikely to have a negative impact on Plack Koha, but it probably will cause opac-detail.pl to load 1-2 seconds slower in CGI Koha.
Comment 57 Katrin Fischer 2020-07-30 22:16:06 UTC
Can you please rebase?

Apply? [(y)es, (n)o, (i)nteractive] y
Applying: Bug 15851: Display analytics links for more cases
Applying: Bug 15851: Only display the analytics link when required
error: sha1 information is lacking or useless (koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACDetail.xsl).
error: could not build fake ancestor
Patch failed at 0001 Bug 15851: Only display the analytics link when required
The copy of the patch that failed is found in: .git/rebase-apply/patch
When you have resolved this problem run "git bz apply --continue".
If you would prefer to skip this patch, instead run "git bz apply --skip".
To restore the original branch and stop patching run "git bz apply --abort".
Patch left in /tmp/Bug-15851-Only-display-the-analytics-link-when-req-6AcS8l.patch
Comment 58 Tomás Cohen Arazi 2020-08-11 11:12:01 UTC
Created attachment 108049 [details] [review]
Bug 15851: Display analytics links for more cases

The current XSLT displays the link to linked analytics only for serials.
This patch makes it show for all the relevant position 7 on the leader
values. I left out a and b as recommended by expert librarians on my
team, but I can revert that if required.

The current implementation adds a new CSS class for each case, so
libraries willing to keep the current behaviour or just have more
granular control on the cases they want the link to display, just can.

This patch makes sense with the follow-up one, which will display the
link only if there are really related records.

To test:
1. Open a non-serial record, notice there's no link to analytics
2. Apply this patch and reload
=> SUCCESS: There's an 'Analytics' link
3. Inspect the produced HTML
=> SUCCESS: A special class with analytic_* value has been added, and
thus we now can control its display through CSS
4. Sign off :-D

Sponsored-by: Orex Digital

Signed-off-by: Hugo Agud <hagud@orex.es>
Comment 59 Tomás Cohen Arazi 2020-08-11 11:12:06 UTC
Created attachment 108050 [details] [review]
Bug 15851: Only display the analytics link when required

This patch makes opac-detail.pl query for analytics the same way it
would do with the generated link (i.e. based on UseControlNumber) and
passes a flag to the XSLT so it displays (or not) the 'Analytics' link.

To test:
1. Apply the first patch
2. Have a known record without analytics
3. Open the record in the OPAC
=> FAIL: It shows the 'Analytics' link
4. Have a record known to have analytics and open in OPAC, on a separate
   tab
=> SUCCESS: It shows the 'Analytics' link
5. Apply this patch and restart_all
6. Reload the tabs
=> SUCCESS: It shows the link where it has to, and hides it where it
shouldn't be displayed
7. Sign off :-D

Sponsored-by: Orex Digital

Signed-off-by: Hugo Agud <hagud@orex.es>
Comment 60 Tomás Cohen Arazi 2020-08-11 11:12:12 UTC
Created attachment 108051 [details] [review]
Bug 15851: (follow-up) Only display the analytics link when required (staff)

This patch replicates the introduced behaviour, for the admin interface.
To test, follow the test plan from the OPAC, but on the intranet.

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 61 Katrin Fischer 2020-08-23 00:55:05 UTC
This works well without UseControlNumber so far, but when I turn it on, the link that was visible before, disappears:

Parent record:
001 15661423

Child record:
LDR 00395    a2200121   4500 = monographic component part
773 	0 		_dCambridge, Mass. : Belknap Press of Harvard University Press, 2009.
_aWilson, Peter H.
_z9780674036345 (hardcover : alk. paper)
_w15661423
_tThe Thirty Years War : 

Can you please check?
Comment 62 Tomás Cohen Arazi 2020-08-23 03:28:09 UTC
(In reply to Katrin Fischer from comment #61)
> This works well without UseControlNumber so far, but when I turn it on, the
> link that was visible before, disappears:
> 
> Parent record:
> 001 15661423
> 
> Child record:
> LDR 00395    a2200121   4500 = monographic component part
> 773 	0 		_dCambridge, Mass. : Belknap Press of Harvard University Press,
> 2009.
> _aWilson, Peter H.
> _z9780674036345 (hardcover : alk. paper)
> _w15661423
> _tThe Thirty Years War : 
> 
> Can you please check?

Will check. If you use master, and the link shows. Does it give you any results? It now shows based on those results.
Comment 63 Katrin Fischer 2020-08-23 10:06:46 UTC
I repeated the test with a serial, as they show the link on master:

Zebra, UseControlNumber = Don't.

On master:
1) Search for Gairm in test data
2) New > Add new child record
3) Check 773$w is set
4) Add 245 and other mandatory fields, save
5) Verify link back and forth between Analytics: and In: works.

Switch UseControlnumber = Do

6) Links back and forth work.

Switch to Elasticsearch, UseControlnumber = Don't

7) Links back and forth work.

Switch to UseControlnumber = Do

8) In: link works, analytics link doesn't (NOT OK)
   rcn:11388674 and (bib-level:a or bib-level:b)
   rcn: alone works.
   bib-level:a alone works.
   Something wrong with the search syntax for Elasticsearch?

Repeating the test on the analytics branch:

9) Zebra, UseControlNumber = Don't: Works
10) Zebra, UseControlNumber = Do: Works (now)
11) Elasticsearch, UseControlNumber = Don't: Works
12) Elasticsearch, UseControlnumber = Do: Link disappears (NOT OK)

After retesting I think the problem last night was either Elasticsearch being active or the record not being properly reindexed when I tried.

Result: UseControlNumber doesn't work with Elasticsearch
Comment 64 Tomás Cohen Arazi 2020-08-27 21:24:10 UTC
This works, and only highlights UseControlNumber doesn't work correctly in ES, which should have it's own bug reported.
Comment 65 Katrin Fischer 2020-08-27 21:26:30 UTC
(In reply to Tomás Cohen Arazi from comment #64)
> This works, and only highlights UseControlNumber doesn't work correctly in
> ES, which should have it's own bug reported.

But with this applied the links all disappear for ES users - I think we should fix the other issue quickly because this will shine a bad light on a nice feature that we want to boldly advertise in release notes.
Comment 66 Tomás Cohen Arazi 2020-08-27 21:30:31 UTC
(In reply to Katrin Fischer from comment #65)
> (In reply to Tomás Cohen Arazi from comment #64)
> > This works, and only highlights UseControlNumber doesn't work correctly in
> > ES, which should have it's own bug reported.
> 
> But with this applied the links all disappear for ES users - I think we
> should fix the other issue quickly because this will shine a bad light on a
> nice feature that we want to boldly advertise in release notes.

I agree. Can you file a bug for ES with your findings and make this one dependent on it? They are really unrelated. And ES it's showing non-working links anyway without this patch set
Comment 67 Katrin Fischer 2020-08-27 21:32:15 UTC
I've filed bug 26313. I suspect changes to this will be needed as the same syntax for the search is used here and in the XSLT we will need to fix there.
Comment 68 Katrin Fischer 2020-08-27 22:24:25 UTC
Created attachment 109267 [details] [review]
Bug 15851: Display analytics links for more cases

The current XSLT displays the link to linked analytics only for serials.
This patch makes it show for all the relevant position 7 on the leader
values. I left out a and b as recommended by expert librarians on my
team, but I can revert that if required.

The current implementation adds a new CSS class for each case, so
libraries willing to keep the current behaviour or just have more
granular control on the cases they want the link to display, just can.

This patch makes sense with the follow-up one, which will display the
link only if there are really related records.

To test:
1. Open a non-serial record, notice there's no link to analytics
2. Apply this patch and reload
=> SUCCESS: There's an 'Analytics' link
3. Inspect the produced HTML
=> SUCCESS: A special class with analytic_* value has been added, and
thus we now can control its display through CSS
4. Sign off :-D

Sponsored-by: Orex Digital

Signed-off-by: Hugo Agud <hagud@orex.es>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 69 Katrin Fischer 2020-08-27 22:24:30 UTC
Created attachment 109268 [details] [review]
Bug 15851: Only display the analytics link when required

This patch makes opac-detail.pl query for analytics the same way it
would do with the generated link (i.e. based on UseControlNumber) and
passes a flag to the XSLT so it displays (or not) the 'Analytics' link.

To test:
1. Apply the first patch
2. Have a known record without analytics
3. Open the record in the OPAC
=> FAIL: It shows the 'Analytics' link
4. Have a record known to have analytics and open in OPAC, on a separate
   tab
=> SUCCESS: It shows the 'Analytics' link
5. Apply this patch and restart_all
6. Reload the tabs
=> SUCCESS: It shows the link where it has to, and hides it where it
shouldn't be displayed
7. Sign off :-D

Sponsored-by: Orex Digital

Signed-off-by: Hugo Agud <hagud@orex.es>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 70 Katrin Fischer 2020-08-27 22:24:36 UTC
Created attachment 109269 [details] [review]
Bug 15851: (follow-up) Only display the analytics link when required (staff)

This patch replicates the introduced behaviour, for the admin interface.
To test, follow the test plan from the OPAC, but on the intranet.

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 71 Jonathan Druart 2020-08-31 09:47:02 UTC
Testing on a fresh ktd:
* Turn on EasyAnalyticalRecords
* /cgi-bin/koha/catalogue/detail.pl?biblionumber=25
Edit > link to host
use barcode from itemnumber 1
=> https://snipboard.io/4TXWVU.jpg
I don't see the link

What am I missing?
Comment 72 Katrin Fischer 2020-08-31 09:57:48 UTC
This is not for EasyAnalytics, but for UseControlnumber. Please follow my test plan from comment#63
Comment 73 Katrin Fischer 2020-09-01 20:14:04 UTC
Created attachment 109459 [details] [review]
Bug 15851: Display analytics links for more cases

The current XSLT displays the link to linked analytics only for serials.
This patch makes it show for all the relevant position 7 on the leader
values. I left out a and b as recommended by expert librarians on my
team, but I can revert that if required.

The current implementation adds a new CSS class for each case, so
libraries willing to keep the current behaviour or just have more
granular control on the cases they want the link to display, just can.

This patch makes sense with the follow-up one, which will display the
link only if there are really related records.

To test:
1. Open a non-serial record, notice there's no link to analytics
2. Apply this patch and reload
=> SUCCESS: There's an 'Analytics' link
3. Inspect the produced HTML
=> SUCCESS: A special class with analytic_* value has been added, and
thus we now can control its display through CSS
4. Sign off :-D

Sponsored-by: Orex Digital

Signed-off-by: Hugo Agud <hagud@orex.es>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 74 Katrin Fischer 2020-09-01 20:14:10 UTC
Created attachment 109460 [details] [review]
Bug 15851: Only display the analytics link when required

This patch makes opac-detail.pl query for analytics the same way it
would do with the generated link (i.e. based on UseControlNumber) and
passes a flag to the XSLT so it displays (or not) the 'Analytics' link.

To test:
1. Apply the first patch
2. Have a known record without analytics
3. Open the record in the OPAC
=> FAIL: It shows the 'Analytics' link
4. Have a record known to have analytics and open in OPAC, on a separate
   tab
=> SUCCESS: It shows the 'Analytics' link
5. Apply this patch and restart_all
6. Reload the tabs
=> SUCCESS: It shows the link where it has to, and hides it where it
shouldn't be displayed
7. Sign off :-D

Sponsored-by: Orex Digital

Signed-off-by: Hugo Agud <hagud@orex.es>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 75 Katrin Fischer 2020-09-01 20:14:15 UTC
Created attachment 109461 [details] [review]
Bug 15851: (follow-up) Only display the analytics link when required (staff)

This patch replicates the introduced behaviour, for the admin interface.
To test, follow the test plan from the OPAC, but on the intranet.

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 76 Katrin Fischer 2020-09-01 20:14:21 UTC
Created attachment 109462 [details] [review]
Bug 15851: (QA follow-up) Fix booleans to uppercase to make this work for Elasticsearch and UseControlNumber

Same test plan as before, but with UseControlNumber = Use and
Elasticsearch.
Comment 77 Jonathan Druart 2020-09-03 13:04:10 UTC
Pushed to master for 20.11, thanks to everybody involved!
Comment 78 Lucas Gass 2020-09-14 21:33:18 UTC
enhancement will not be backported to 20.05.x series