Bug 27428 - Show the number of records in the bibliographic record detail page with ElasticSearch
Summary: Show the number of records in the bibliographic record detail page with Elast...
Status: BLOCKED
Alias: None
Product: Koha
Classification: Unclassified
Component: Searching - Elasticsearch (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: Ivan Dziuba
QA Contact:
URL:
Keywords:
Depends on: 27113
Blocks:
  Show dependency treegraph
 
Reported: 2021-01-13 18:17 UTC by Ivan Dziuba
Modified: 2024-08-13 17:29 UTC (History)
14 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Bug 27428: Show the number of records in the bibliographic record detail page with ElasticSearch. (10.70 KB, patch)
2021-01-14 13:26 UTC, Ivan Dziuba
Details | Diff | Splinter Review
Bug 27428: Show the number of records in the bibliographic record detail page with ElasticSearch. (11.24 KB, patch)
2021-01-15 14:50 UTC, Ivan Dziuba
Details | Diff | Splinter Review
Bug 27428: Show the number of records in the bibliographic record detail page with ElasticSearch. (11.27 KB, patch)
2021-03-08 23:40 UTC, Ivan Dziuba
Details | Diff | Splinter Review
Bug 27428: Show the number of records in the bibliographic record detail page with ElasticSearch. (11.31 KB, patch)
2021-04-21 21:49 UTC, Ivan Dziuba
Details | Diff | Splinter Review
Bug 27428: Show the number of records in the bibliographic record detail page with ElasticSearch. (11.21 KB, patch)
2021-04-22 22:24 UTC, Ivan Dziuba
Details | Diff | Splinter Review
Bug 27428: Show the number of records in the bibliographic record detail page with ElasticSearch. (11.30 KB, patch)
2021-05-06 13:44 UTC, Lund University Sandbox
Details | Diff | Splinter Review
Bug 27428: Show the number of records in the bibliographic record detail page with ElasticSearch. (10.98 KB, patch)
2022-03-23 17:36 UTC, Shi Yao Wang
Details | Diff | Splinter Review
Bug 27428: Show the number of records in the bibliographic record detail page with ElasticSearch. (11.37 KB, patch)
2022-08-22 19:34 UTC, Shi Yao Wang
Details | Diff | Splinter Review
Bug 27428: Show the number of records in the bibliographic record detail page with ElasticSearch. (11.38 KB, patch)
2022-08-22 19:46 UTC, Shi Yao Wang
Details | Diff | Splinter Review
Bug 27428: Show the number of records in the bibliographic record detail page with ElasticSearch. (11.09 KB, patch)
2022-08-23 14:23 UTC, Shi Yao Wang
Details | Diff | Splinter Review
Bug 27428: Show the number of records in the bibliographic record detail page with ElasticSearch. (11.14 KB, patch)
2023-01-11 21:07 UTC, solene.ngamga
Details | Diff | Splinter Review
Bug 27428: (QA follow-up) Add missing POD, remove ES template literals in opac-display-record-count.js (2.23 KB, patch)
2023-03-28 16:33 UTC, Hammat wele
Details | Diff | Splinter Review
Bug 27428: Show the number of records in the bibliographic record detail page with ElasticSearch. (11.19 KB, patch)
2023-08-17 09:36 UTC, Peter Vashchuk
Details | Diff | Splinter Review
Bug 27428: (QA follow-up) Add missing POD, remove ES template literals in opac-display-record-count.js (2.29 KB, patch)
2023-08-17 09:36 UTC, Peter Vashchuk
Details | Diff | Splinter Review
Bug 27428: Show the number of records in the bibliographic record detail page with ElasticSearch. (11.21 KB, patch)
2023-11-08 01:23 UTC, Hammat wele
Details | Diff | Splinter Review
Bug 27428: (QA follow-up) Add missing POD, remove ES template literals in opac-display-record-count.js (1.57 KB, patch)
2023-11-08 01:23 UTC, Hammat wele
Details | Diff | Splinter Review
Bug 27428: (follow-up) perltidy, change the atomic file to the newer format, moving system preference to Features section and Fixing opac-display-record-count.js (10.91 KB, patch)
2023-11-08 01:23 UTC, Hammat wele
Details | Diff | Splinter Review
Bug 27428: (follow-up) Fix Session (980 bytes, patch)
2024-01-24 15:33 UTC, Hammat wele
Details | Diff | Splinter Review
Bug 27428: Show the number of records in the bibliographic record detail page with ElasticSearch. (11.21 KB, patch)
2024-04-09 13:31 UTC, Hammat wele
Details | Diff | Splinter Review
Bug 27428: (QA follow-up) Add missing POD, remove ES template literals in opac-display-record-count.js (1.57 KB, patch)
2024-04-09 13:31 UTC, Hammat wele
Details | Diff | Splinter Review
Bug 27428: (follow-up) perltidy, change the atomic file to the newer format, moving system preference to Features section and Fixing opac-display-record-count.js (9.29 KB, patch)
2024-04-09 13:31 UTC, Hammat wele
Details | Diff | Splinter Review
Bug 27428: (follow-up) Fix Session (980 bytes, patch)
2024-04-09 13:31 UTC, Hammat wele
Details | Diff | Splinter Review
Screenshot - display for record detail page - [[object Object]] (89.77 KB, image/png)
2024-06-02 22:12 UTC, David Nind
Details
Bug 27428: (follow-up) show the number instead [[object Object]], move OPACDisplayRecordCount to the 'Features' section (3.20 KB, patch)
2024-06-12 21:58 UTC, Hammat wele
Details | Diff | Splinter Review
Bug 27428: Show the number of records in the bibliographic record detail page with ElasticSearch. (11.26 KB, patch)
2024-06-14 21:40 UTC, David Nind
Details | Diff | Splinter Review
Bug 27428: (QA follow-up) Add missing POD, remove ES template literals in opac-display-record-count.js (1.62 KB, patch)
2024-06-14 21:40 UTC, David Nind
Details | Diff | Splinter Review
Bug 27428: (follow-up) perltidy, change the atomic file to the newer format, moving system preference to Features section and Fixing opac-display-record-count.js (9.34 KB, patch)
2024-06-14 21:40 UTC, David Nind
Details | Diff | Splinter Review
Bug 27428: (follow-up) Fix Session (1.00 KB, patch)
2024-06-14 21:40 UTC, David Nind
Details | Diff | Splinter Review
Bug 27428: (follow-up) show the number instead [[object Object]], move OPACDisplayRecordCount to the 'Features' section (3.24 KB, patch)
2024-06-14 21:40 UTC, David Nind
Details | Diff | Splinter Review
Bug 27428: (follow-up) Update system preference description (1.49 KB, patch)
2024-06-14 22:17 UTC, David Nind
Details | Diff | Splinter Review
Bug 27428: Show the number of records in the bibliographic record detail page with ElasticSearch. (11.26 KB, patch)
2024-08-13 17:29 UTC, Hammat wele
Details | Diff | Splinter Review
Bug 27428: (QA follow-up) Add missing POD, remove ES template literals in opac-display-record-count.js (1.62 KB, patch)
2024-08-13 17:29 UTC, Hammat wele
Details | Diff | Splinter Review
Bug 27428: (follow-up) perltidy, change the atomic file to the newer format, moving system preference to Features section and Fixing opac-display-record-count.js (9.34 KB, patch)
2024-08-13 17:29 UTC, Hammat wele
Details | Diff | Splinter Review
Bug 27428: (follow-up) Fix Session (1.00 KB, patch)
2024-08-13 17:29 UTC, Hammat wele
Details | Diff | Splinter Review
Bug 27428: (follow-up) show the number instead [[object Object]], move OPACDisplayRecordCount to the 'Features' section (3.38 KB, patch)
2024-08-13 17:29 UTC, Hammat wele
Details | Diff | Splinter Review
Bug 27428: (follow-up) Update system preference description (1.49 KB, patch)
2024-08-13 17:29 UTC, Hammat wele
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Ivan Dziuba 2021-01-13 18:17:46 UTC
This preference only for OPAC to show the number of records next to search links in the bibliographic record detail page.
Comment 1 Ivan Dziuba 2021-01-14 13:26:51 UTC Comment hidden (obsolete)
Comment 2 Ivan Dziuba 2021-01-15 14:50:16 UTC Comment hidden (obsolete)
Comment 3 Frank Hansen 2021-02-25 15:43:39 UTC
I have applied the patch but I can't get it to work. Maybe I misunderstand how it is supposed to work. Can you clarify what it should look like, maybe post a screen shots?
Comment 4 Owen Leonard 2021-02-25 16:05:26 UTC
I see an error in the console:

Could not compile /kohadevbox/koha/opac/svc/elasticsearch/opac-autocomplete.pl: Can't locate Switch.pm in @INC (you may need to install the Switch module)
Comment 5 Timothy Alexis Vass 2021-03-04 13:19:08 UTC
I see this line in the patch for opac/svc/elasticsearch/opac-autocomplete.pl:
8 use Switch;

But it doesn't seem to be used in the code?
There seems to be other modules used which aren't used either.
Comment 6 Timothy Alexis Vass 2021-03-04 13:21:20 UTC
Sorry, the Switch module is the only one which isn't actually used in the code.

There are no switch or case statements.
Comment 7 Björn Nylén 2021-03-04 14:31:53 UTC
I recall dependency on Text::Unaccent was recently removed by Bug 14759, replaced by Unicode::Normalize. We shouldn't ad it back in, perhaps.
Comment 8 Ivan Dziuba 2021-03-08 23:40:26 UTC Comment hidden (obsolete)
Comment 9 Séverine Queune 2021-03-11 13:35:45 UTC
(In reply to Frank Hansen from comment #3)
> I have applied the patch but I can't get it to work. Maybe I misunderstand
> how it is supposed to work. Can you clarify what it should look like, maybe
> post a screen shots?

Same as Franck, I don't see differents in bib record page when I enable the syspref. It seems I misunderstood something too.
Comment 10 Ivan Dziuba 2021-04-21 21:49:38 UTC
Created attachment 119980 [details] [review]
Bug 27428: Show the number of records in the bibliographic record detail page with ElasticSearch.

Tests:
1. Apply this patch;
2. In the Preference system - OPACDisplayRecordCount -> Show;
3. We can see the number of records next to search links in the bibliographic record detail page in the OPAC.

Bug 27113: ElasticSearch: Autocomplete in input search. Use Unicode::Normalize instead Text::Unaccent.
Comment 11 Owen Leonard 2021-04-22 13:03:40 UTC
This patch includes elasticsearch/opac-autocomplete.pl. Does that change belong here?
Comment 12 Blou 2021-04-22 13:23:49 UTC
That shoudl be opac-elasticsearch.pl (or similar generic name) in here and Bug 27113
Comment 13 Ivan Dziuba 2021-04-22 22:24:20 UTC
Created attachment 120034 [details] [review]
Bug 27428: Show the number of records in the bibliographic record detail page with ElasticSearch.

Tests:
1. Apply this patch;
2. In the Preference system - OPACDisplayRecordCount -> Show;
3. We can see the number of records next to search links in the bibliographic record detail page in the OPAC.
Comment 14 Lund University Sandbox 2021-05-06 13:44:10 UTC
Created attachment 120633 [details] [review]
Bug 27428: Show the number of records in the bibliographic record detail page with ElasticSearch.

Tests:
1. Apply this patch;
2. In the Preference system - OPACDisplayRecordCount -> Show;
3. We can see the number of records next to search links in the bibliographic record detail page in the OPAC.

Signed-off-by: Stina Hallin <stina.hallin@ub.lu.se>
Comment 15 Stina Hallin 2021-05-06 13:46:35 UTC
The number of records did show, but some of the search words got the number 0, and that is obviously wrong. See:
Subject(s): Clans -- Scotland -- Great Glen -- History -- 17th century [1] | Clans -- Scotland -- Great Glen -- History -- 18th century [1] | Jacobites [2] | Great Glen (Scotland) -- History [1] | Highlands (Scotland) -- History [0] | Scotland -- History -- 17th century [1] | Scotland -- History -- 18th century [0]
From opac-detail.pl?biblionumber=60.
Comment 16 Marcel de Rooy 2021-07-09 08:43:40 UTC
(In reply to Stina Hallin from comment #15)
> The number of records did show, but some of the search words got the number
> 0, and that is obviously wrong. See:
> Subject(s): Clans -- Scotland -- Great Glen -- History -- 17th century [1] |
> Clans -- Scotland -- Great Glen -- History -- 18th century [1] | Jacobites
> [2] | Great Glen (Scotland) -- History [1] | Highlands (Scotland) -- History
> [0] | Scotland -- History -- 17th century [1] | Scotland -- History -- 18th
> century [0]
> From opac-detail.pl?biblionumber=60.

Stina, if you find things that are obviously wrong, you may change the status of the patch to Failed QA.
Comment 17 Marcel de Rooy 2021-07-09 08:45:10 UTC
+('OPACDisplayRecordCount','0',NULL,NULL,'YesNo')

Please add description here
Comment 18 Marcel de Rooy 2021-07-09 08:46:34 UTC
+              default: no
+              choices:
+                  1: Show
+                  0: "Don't show"

You probably mean default 0 ?
Comment 19 Shi Yao Wang 2022-03-23 17:36:48 UTC
Created attachment 132068 [details] [review]
Bug 27428: Show the number of records in the bibliographic record detail page with ElasticSearch.

Tests:
1. Apply this patch;
2. In the Preference system - OPACDisplayRecordCount -> Show;
3. We can see the number of records next to search links in the bibliographic record detail page in the OPAC.

Signed-off-by: Stina Hallin <stina.hallin@ub.lu.se>
Comment 20 Séverine Queune 2022-03-30 15:57:04 UTC
Ok, I got it now !
It works nice :)

I've got few questions though before signing it.

I wonder what is the perimeter of the application : does the feature applied for every search link available in the record ?

I saw that some special signs are not taken into account in the search but some are kept such like ';' or ':'. Is it a specific reason for that, for I don't get the logic ?

This special signs can lead to unsuccessful searches so, for some records with a lot of informations, I wonder if, in the case result is [0], it's useful to display the information (see screenshot https://snipboard.io/RvlewS.jpg)
Comment 21 Shi Yao Wang 2022-08-22 19:34:32 UTC
Created attachment 139625 [details] [review]
Bug 27428: Show the number of records in the bibliographic record detail page with ElasticSearch.

Tests:
1. Apply this patch;
2. In the Preference system - OPACDisplayRecordCount -> Show;
3. We can see the number of records next to search links in the bibliographic record detail page in the OPAC.

Signed-off-by: Stina Hallin <stina.hallin@ub.lu.se>
Comment 22 Shi Yao Wang 2022-08-22 19:46:25 UTC
Created attachment 139626 [details] [review]
Bug 27428: Show the number of records in the bibliographic record detail page with ElasticSearch.

Tests:
1. Apply this patch;
2. In the Preference system - OPACDisplayRecordCount -> Show;
3. We can see the number of records next to search links in the bibliographic record detail page in the OPAC.

Signed-off-by: Stina Hallin <stina.hallin@ub.lu.se>
Comment 23 Shi Yao Wang 2022-08-23 14:23:17 UTC
Created attachment 139681 [details] [review]
Bug 27428: Show the number of records in the bibliographic record detail page with ElasticSearch.

Tests:
1. Apply this patch;
2. In the Preference system - OPACDisplayRecordCount -> Show;
3. We can see the number of records next to search links in the bibliographic record detail page in the OPAC.

Signed-off-by: Stina Hallin <stina.hallin@ub.lu.se>
Comment 24 solene.ngamga 2023-01-11 21:07:15 UTC
Created attachment 145222 [details] [review]
Bug 27428: Show the number of records in the bibliographic record detail page with ElasticSearch.

Tests:
1. Apply this patch;
2. In the Preference system - OPACDisplayRecordCount -> Show;
3. We can see the number of records next to search links in the bibliographic record detail page in the OPAC.

Signed-off-by: Stina Hallin <stina.hallin@ub.lu.se>
Signed-off-by: Solene Ngamga <solene.ngamga@inLibro.com>
Comment 25 Marcel de Rooy 2023-02-24 10:56:55 UTC
 FAIL   Koha/SearchEngine/Elasticsearch/Browse.pm
   OK     critic
   OK     forbidden patterns
   OK     git manipulation
   OK     pod
   FAIL   pod coverage
                POD is missing for 'count_record'
   SKIP   spelling
   OK     valid

 OK     installer/data/mysql/mandatory/sysprefs.sql
   OK     git manipulation
   OK     semicolon
   OK     sysprefs_order

 FAIL   koha-tmpl/opac-tmpl/bootstrap/en/includes/doc-head-close.inc
   FAIL   filters
                asset_must_be_raw at line 52 (    [% Asset.js("js/opac-display-record-count.js") %])
   OK     forbidden patterns
   OK     git manipulation
   OK     js_in_body
   SKIP   spelling
   OK     tt_valid
   OK     valid_template

 OK     koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt
   OK     filters
   OK     forbidden patterns
   OK     git manipulation
   OK     js_in_body
   SKIP   spelling
   OK     tt_valid
   OK     valid_template

 FAIL   koha-tmpl/opac-tmpl/bootstrap/js/opac-display-record-count.js
   FAIL   ES template literals
                ES template literals found (    var regex = `a[href*="${regex_es_link}"]`;) - See bug 24725
Comment 26 Hammat wele 2023-03-28 16:33:33 UTC
Created attachment 148842 [details] [review]
Bug 27428: (QA follow-up) Add missing POD, remove ES template literals in opac-display-record-count.js
Comment 27 Peter Vashchuk 2023-08-17 09:36:00 UTC
Created attachment 154509 [details] [review]
Bug 27428: Show the number of records in the bibliographic record detail page with ElasticSearch.

Tests:
1. Apply this patch;
2. In the Preference system - OPACDisplayRecordCount -> Show;
3. We can see the number of records next to search links in the bibliographic record detail page in the OPAC.

Signed-off-by: Stina Hallin <stina.hallin@ub.lu.se>
Signed-off-by: Solene Ngamga <solene.ngamga@inLibro.com>
Signed-off-by: Petro Vashchuk <stalkernoid@gmail.com>
Comment 28 Peter Vashchuk 2023-08-17 09:36:03 UTC
Created attachment 154510 [details] [review]
Bug 27428: (QA follow-up) Add missing POD, remove ES template literals in opac-display-record-count.js

Signed-off-by: Petro Vashchuk <stalkernoid@gmail.com>
Comment 29 Katrin Fischer 2023-10-14 20:25:55 UTC
Hi, this is a really interesting feature!

Some notes:

1) The QA test tools are currently still failing, but it's only a perltidy that is needed.

2) The database update still has the old format and should be moved to the newer atomic update template.

3) The system preference is added correctly, but should
a) Include a note that this feature is "Elasticsearch only"
b) Be moved to the "Features" section instead of the "Did you mean" where it appears now.

4) It didn't work in my testing :( Maybe something broke with changes made to the OPAC since this was submitted the first time?

* I used ktd --es7 up
* Made sure SearchEngine was Elasticsearch and search worked
* Applied patch
* restart_all
* Turned on OPACDisplayRecordCount system preference

I don't see any errors in the console, but the JSON responses come back empty, possibly because the q param is empty::

http://localhost:8080/cgi-bin/koha/svc/elasticsearch/opac-elasticsearch.pl?q=[]&key=nb_notice ?

I searched for "perl" in a MARC21 sample database and paged through a lot of the results with no counts showing.

5) Code review
* Please translate code comments if you want to keep them:
+/* Regex pour tous les URL avec un recherche */

This uses the older /svc pattern, we might want to get a second more technical review on this one.
Comment 30 Hammat wele 2023-11-08 01:23:17 UTC
Created attachment 158639 [details] [review]
Bug 27428: Show the number of records in the bibliographic record detail page with ElasticSearch.

Tests:
1. Apply this patch;
2. In the Preference system - OPACDisplayRecordCount -> Show;
3. We can see the number of records next to search links in the bibliographic record detail page in the OPAC.

Signed-off-by: Stina Hallin <stina.hallin@ub.lu.se>
Signed-off-by: Solene Ngamga <solene.ngamga@inLibro.com>
Signed-off-by: Petro Vashchuk <stalkernoid@gmail.com>
Comment 31 Hammat wele 2023-11-08 01:23:21 UTC
Created attachment 158640 [details] [review]
Bug 27428: (QA follow-up) Add missing POD, remove ES template literals in opac-display-record-count.js

Signed-off-by: Petro Vashchuk <stalkernoid@gmail.com>
Comment 32 Hammat wele 2023-11-08 01:23:26 UTC
Created attachment 158641 [details] [review]
Bug 27428: (follow-up) perltidy, change the atomic file to the newer format, moving system preference to Features section and Fixing opac-display-record-count.js
Comment 33 Hammat wele 2024-01-24 15:33:48 UTC
Created attachment 161349 [details] [review]
Bug 27428: (follow-up) Fix Session
Comment 34 Hammat wele 2024-04-09 13:31:02 UTC
Created attachment 164557 [details] [review]
Bug 27428: Show the number of records in the bibliographic record detail page with ElasticSearch.

Tests:
1. Apply this patch;
2. In the Preference system - OPACDisplayRecordCount -> Show;
3. We can see the number of records next to search links in the bibliographic record detail page in the OPAC.

Signed-off-by: Stina Hallin <stina.hallin@ub.lu.se>
Signed-off-by: Solene Ngamga <solene.ngamga@inLibro.com>
Signed-off-by: Petro Vashchuk <stalkernoid@gmail.com>
Comment 35 Hammat wele 2024-04-09 13:31:06 UTC
Created attachment 164558 [details] [review]
Bug 27428: (QA follow-up) Add missing POD, remove ES template literals in opac-display-record-count.js

Signed-off-by: Petro Vashchuk <stalkernoid@gmail.com>
Comment 36 Hammat wele 2024-04-09 13:31:10 UTC
Created attachment 164559 [details] [review]
Bug 27428: (follow-up) perltidy, change the atomic file to the newer format, moving system preference to Features section and Fixing opac-display-record-count.js
Comment 37 Hammat wele 2024-04-09 13:31:14 UTC
Created attachment 164560 [details] [review]
Bug 27428: (follow-up) Fix Session
Comment 38 David Nind 2024-06-02 22:12:18 UTC
Created attachment 167328 [details]
Screenshot - display for record detail page - [[object Object]]

For me, [[object Object]] is being displayed instead of the number of records.

I've attached a screenshot of what I'm seeing.

I also did a complete reindex (not sure whether this is necessary).

Other things I noted:
1. OPACDisplayRecordCount is still listed under the "Did you mean/spell checking" section, rather than "Features"
2. Should the description have a note saying only for Elasticsearch/Open Search?
3. If search engine is Zebra, is currently showing the [[object Object]]

Testing notes (using KTD):
1. Start up KTD with Elasticsearch: ktd --es8 up or ktd --es7 up
2. Apply the patch
3. Update the database: updatedatabase
4. Restart everything: flush_memcached and restart_all
5. Reindex: koha-elasticsearch --rebuild -d -b -a kohadev
Comment 39 Hammat wele 2024-06-12 21:58:32 UTC
Created attachment 167677 [details] [review]
Bug 27428: (follow-up) show the number instead [[object Object]], move OPACDisplayRecordCount to the 'Features' section
Comment 40 David Nind 2024-06-14 21:40:33 UTC
Created attachment 167767 [details] [review]
Bug 27428: Show the number of records in the bibliographic record detail page with ElasticSearch.

Tests:
1. Apply this patch;
2. In the Preference system - OPACDisplayRecordCount -> Show;
3. We can see the number of records next to search links in the bibliographic record detail page in the OPAC.

Signed-off-by: Stina Hallin <stina.hallin@ub.lu.se>
Signed-off-by: Solene Ngamga <solene.ngamga@inLibro.com>
Signed-off-by: Petro Vashchuk <stalkernoid@gmail.com>
Signed-off-by: David Nind <david@davidnind.com>
Comment 41 David Nind 2024-06-14 21:40:37 UTC
Created attachment 167768 [details] [review]
Bug 27428: (QA follow-up) Add missing POD, remove ES template literals in opac-display-record-count.js

Signed-off-by: Petro Vashchuk <stalkernoid@gmail.com>
Signed-off-by: David Nind <david@davidnind.com>
Comment 42 David Nind 2024-06-14 21:40:40 UTC
Created attachment 167769 [details] [review]
Bug 27428: (follow-up) perltidy, change the atomic file to the newer format, moving system preference to Features section and Fixing opac-display-record-count.js

Signed-off-by: David Nind <david@davidnind.com>
Comment 43 David Nind 2024-06-14 21:40:43 UTC
Created attachment 167770 [details] [review]
Bug 27428: (follow-up) Fix Session

Signed-off-by: David Nind <david@davidnind.com>
Comment 44 David Nind 2024-06-14 21:40:47 UTC
Created attachment 167771 [details] [review]
Bug 27428: (follow-up) show the number instead [[object Object]], move OPACDisplayRecordCount to the 'Features' section

Signed-off-by: David Nind <david@davidnind.com>
Comment 45 David Nind 2024-06-14 22:17:28 UTC
Created attachment 167774 [details] [review]
Bug 27428: (follow-up) Update system preference description

Add Elasticsearch only to OPACDisplayRecordCount description.
Comment 46 David Nind 2024-06-14 22:21:53 UTC
I added a follow-up to update the new system preference description to indicate that it is Elasticsearch only.

I got a bit confused when signing off - if I started up KTD with Elasticsearch, it worked as expected.

If I switched the search engine to Zebra, rebuilt the index, and restarted everything, it was showing the counts in the OPAC.

However, if I started up KTD without Elasticsearch it did not display the counts.
Comment 47 David Nind 2024-06-14 22:26:34 UTC
Some more comments, but not something I'm sure of any more - so will leave to the QA team:

1. The change using the <b> tag for the count, I think we should be using <strong> to make the count bold.

2. Maybe a class should be used for the count style, so that libraries can customise the CSS. For some, the count in black and bold may stand out a little too much on the page (it does for me).
Comment 48 David Cook 2024-06-16 23:38:47 UTC
Can someone explain the bug title? "Show the number of records in the bibliographic record" doesn't make sense to me. Is that supposed to be "Show the number of item records"?
Comment 49 David Cook 2024-06-16 23:45:24 UTC
Is this a brand new development or is this something inLibro has had around for a while?

I haven't read through everything here, but noticing some issues.

While we don't explicitly have a coding guideline for this, we shouldn't be adding new "svc" scripts. API calls should be added via the REST API.

I see that "opac/svc/elasticsearch/opac-elasticsearch.pl" doesn't have any authentication or authorization (even if it's a public endpoint, this is needed for appropriate session handling at the very least), and has completely non-standard output. 

It's also not clear to me why you're using Unicode::Normalize here. The "not_symbols" bit in "koha-tmpl/opac-tmpl/bootstrap/js/opac-display-record-count.js" is also weird.

I could be missing something but I have a feeling that something isn't right here.
Comment 50 David Cook 2024-06-16 23:47:00 UTC
Comment on attachment 167770 [details] [review]
Bug 27428: (follow-up) Fix Session

Review of attachment 167770 [details] [review]:
-----------------------------------------------------------------

::: opac/svc/elasticsearch/opac-elasticsearch.pl
@@ +10,4 @@
>  
>  my $browser = Koha::SearchEngine::Elasticsearch::Browse->new( { index => 'biblios' } );
>  my $cgi     = CGI->new;
> +my $session = CGI::Session->load() or die CGI::Session->errstr();

This isn't how we do this in Koha. This is also why you'd use something like check_api_auth() (not that you should be doing a "svc" script at all), as you'd get a $sessionID that you could then use with C4::Auth::get_session($sessionID).

But really this should be a REST API endpoint.
Comment 51 David Cook 2024-06-16 23:47:51 UTC
Apologies if I sound grumpy. It's not my intention. It's first thing Monday morning ﷐[U+1F605]﷑.
Comment 52 Katrin Fischer 2024-06-17 08:12:49 UTC
(In reply to David Cook from comment #48)
> Can someone explain the bug title? "Show the number of records in the
> bibliographic record" doesn't make sense to me. Is that supposed to be "Show
> the number of item records"?

I think it's probably a hard one to explain in a short phrase. What it means is:
Show the number of records you will find, when clicking on that search link in the record. 

I know libraries would love this especially for the 7xx/8xx linkings (how many linked volumes? how many analytics?) but also cool for subjects to see which search route is the most promising.
Comment 53 Blou 2024-06-17 13:21:35 UTC
You do sound grumpy :) but I can justify the current state of affair.
Katryn already explained the functionality.

We coded that many years ago along Bug 27113.  We asked the community HOW to do it to avoid exactly this type of comment (which I don't mind in essence, but the timing is off).  As usual, the target kept moving.

We tried to share code between the two bz, or at least architecture.  But Bug 27113 got blocked by another one.

Your points are probably all valid, but until Bug 27113 (autocomplete) gets moving, were not going to rearchitecture this one as we don't want this little feature complicating our future development of the big one.

We rebase to keep it valid for the libraries who want it, and to give it to our users.
Comment 54 David Cook 2024-06-17 23:15:48 UTC
(In reply to Katrin Fischer from comment #52)
> (In reply to David Cook from comment #48)
> > Can someone explain the bug title? "Show the number of records in the
> > bibliographic record" doesn't make sense to me. Is that supposed to be "Show
> > the number of item records"?
> 
> I think it's probably a hard one to explain in a short phrase. What it means
> is:
> Show the number of records you will find, when clicking on that search link
> in the record. 
> 
> I know libraries would love this especially for the 7xx/8xx linkings (how
> many linked volumes? how many analytics?) but also cool for subjects to see
> which search route is the most promising.

I wouldn't have guessed that, so thanks for the explanation! That's interesting! Seems like it could be difficult to do in a high performance way...
Comment 55 David Cook 2024-06-17 23:24:24 UTC
(In reply to Blou from comment #53)
> You do sound grumpy :)

Haha thanks for the confirmation :)

> We coded that many years ago along Bug 27113.  We asked the community HOW to
> do it to avoid exactly this type of comment (which I don't mind in essence,
> but the timing is off).  As usual, the target kept moving.

Thanks for mentioning that. I had a feeling that was probably the case, but wanted to check. 

> We tried to share code between the two bz, or at least architecture.  But
> Bug 27113 got blocked by another one.
> 
> Your points are probably all valid, but until Bug 27113 (autocomplete) gets
> moving, were not going to rearchitecture this one as we don't want this
> little feature complicating our future development of the big one.

Fair enough.

I am still curious about the use of Unicode::Normalize here though.
Comment 56 Blou 2024-06-18 12:33:16 UTC
I didn't code it, but my first instinct would be that it's related to Bug 27113, again.  You don't want to bother with accents when comparing for an autocomplete.

I read in another comment you suggest using Unicode::Collate::Locale instead of Unicode::Normalize, and hopefully it'll be caught whenever a "real" release is done for either patch.
Comment 57 David Cook 2024-06-18 23:10:40 UTC
(In reply to Blou from comment #56)
> I didn't code it, but my first instinct would be that it's related to Bug
> 27113, again.  You don't want to bother with accents when comparing for an
> autocomplete.
> 
> I read in another comment you suggest using Unicode::Collate::Locale instead
> of Unicode::Normalize, and hopefully it'll be caught whenever a "real"
> release is done for either patch.

Ah right the autocomplete. Makes sense I think. 

Overall, I think that you've answered most of my questions. I think the SVC vs REST API question needs to be answered and it looks like that question is mostly being asked in bug 27113, so I think BLOCKED makes sense for a status here.

Also adding a dependency on bug 27113.
Comment 58 Hammat wele 2024-08-13 17:29:32 UTC
Created attachment 170274 [details] [review]
Bug 27428: Show the number of records in the bibliographic record detail page with ElasticSearch.

Tests:
1. Apply this patch;
2. In the Preference system - OPACDisplayRecordCount -> Show;
3. We can see the number of records next to search links in the bibliographic record detail page in the OPAC.

Signed-off-by: Stina Hallin <stina.hallin@ub.lu.se>
Signed-off-by: Solene Ngamga <solene.ngamga@inLibro.com>
Signed-off-by: Petro Vashchuk <stalkernoid@gmail.com>
Signed-off-by: David Nind <david@davidnind.com>
Comment 59 Hammat wele 2024-08-13 17:29:36 UTC
Created attachment 170275 [details] [review]
Bug 27428: (QA follow-up) Add missing POD, remove ES template literals in opac-display-record-count.js

Signed-off-by: Petro Vashchuk <stalkernoid@gmail.com>
Signed-off-by: David Nind <david@davidnind.com>
Comment 60 Hammat wele 2024-08-13 17:29:41 UTC
Created attachment 170276 [details] [review]
Bug 27428: (follow-up) perltidy, change the atomic file to the newer format, moving system preference to Features section and Fixing opac-display-record-count.js

Signed-off-by: David Nind <david@davidnind.com>
Comment 61 Hammat wele 2024-08-13 17:29:45 UTC
Created attachment 170277 [details] [review]
Bug 27428: (follow-up) Fix Session

Signed-off-by: David Nind <david@davidnind.com>
Comment 62 Hammat wele 2024-08-13 17:29:49 UTC
Created attachment 170278 [details] [review]
Bug 27428: (follow-up) show the number instead [[object Object]], move OPACDisplayRecordCount to the 'Features' section

Signed-off-by: David Nind <david@davidnind.com>
Comment 63 Hammat wele 2024-08-13 17:29:53 UTC
Created attachment 170279 [details] [review]
Bug 27428: (follow-up) Update system preference description

Add Elasticsearch only to OPACDisplayRecordCount description.