Bug 37057

Summary: OPACShowUnusedAuthorities displays unused authorities regardless
Product: Koha Reporter: Esther Melander <esther.melander>
Component: OPACAssignee: Nick Clemens (kidclamp) <nick>
Status: Pushed to main --- QA Contact: Martin Renvoize <martin.renvoize>
Severity: normal    
Priority: P5 - low CC: david, nick, phil
Version: 23.11Keywords: regression
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=37069
Change sponsored?: --- Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
24.11.00
Circulation function:
Bug Depends on: 12478    
Bug Blocks:    
Attachments: Bug 37057: Restore filtering of unused authorities
Bug 37057: Restore filtering of unused authorities
Bug 37057: Restore filtering of unused authorities

Description Esther Melander 2024-06-07 17:44:38 UTC
To replicate:

1. Create a topic term authority "Example"
2. Duplicate that authority so there are two
3. Find a record and add the topical term "Example"
4. Link the topical term in the record to one of the two Example authorities.
5. Set OPACShowUnusedAuthorities to show.
6. Ensure OpacAuthorities is set to Allow.
7. Search Authorities in the OPAC for "Example"

A list should be returned with Example listed twice. One of the authorities should display it is linked to a record and one should be "0" for no link.

8. Change OPACShowUnusedAuthorities to don't show
9. Refresh the page and repeat the authority search for "Example"

See that the search results are identical. The Example result with no linked records still displays. I would have expected it to not display, unless there is some other preference or option that needs to be set.
Comment 1 Phil Ringnalda 2024-06-10 17:25:54 UTC
That would be from bug 12478 in https://git.koha-community.org/Koha-community/Koha/commit/0002bbc72a42b4c4223e20c66ef032c20f48ba19 - apparently at one point, Elasticsearch hadn't yet implemented authority usage counts, so they just commented out the whole OPACShowUnusedAuthorities feature for ES and Zebra, and left it that way.
Comment 2 Nick Clemens (kidclamp) 2024-06-11 12:37:29 UTC
Created attachment 167629 [details] [review]
Bug 37057: Restore filtering of unused authorities

Bug 12478 commented this code out, however, we do return the 'used' parameter in ES authority searches. While
we should implement the feature for both ES and Zebra as an index, we can restore this behaviour here.

To test:
1 - Search authorities on OPAC with SearchEngine syspref set to both Elasticsearch and Zebra
    I just searched for 'a'
2 - Confirm results with no usage are included
3 - Test with both values of OPACShowUnusedAuthorities
4 - Apply patch
5 - Repeat searches with both engines and syspref settings
6 - Confirm unused authorities not shown in either engine when syspref is "Don't show"
7 - Conifrm unused authorities shown in both engines when syspref is "Show"
Comment 3 David Nind 2024-06-13 23:05:05 UTC
Created attachment 167705 [details] [review]
Bug 37057: Restore filtering of unused authorities

Bug 12478 commented this code out, however, we do return the 'used' parameter in ES authority searches. While
we should implement the feature for both ES and Zebra as an index, we can restore this behaviour here.

To test:
1 - Search authorities on OPAC with SearchEngine syspref set to both Elasticsearch and Zebra
    I just searched for 'a'
2 - Confirm results with no usage are included
3 - Test with both values of OPACShowUnusedAuthorities
4 - Apply patch
5 - Repeat searches with both engines and syspref settings
6 - Confirm unused authorities not shown in either engine when syspref is "Don't show"
7 - Conifrm unused authorities shown in both engines when syspref is "Show"

Signed-off-by: David Nind <david@davidnind.com>
Comment 4 David Nind 2024-06-13 23:17:24 UTC
Testing notes (using KTD):

1. I used the word 'central' to show used and unused terms on the search results.

2. The pagination for OPAC authority search results is currently not working (not because of this bug). If you try and navigate to the next page of results, it just returns you to the authority search form. I have logged Bug 37086 for this.
Comment 5 Martin Renvoize 2024-06-28 15:53:02 UTC
Created attachment 168271 [details] [review]
Bug 37057: Restore filtering of unused authorities

Bug 12478 commented this code out, however, we do return the 'used' parameter in ES authority searches. While
we should implement the feature for both ES and Zebra as an index, we can restore this behaviour here.

To test:
1 - Search authorities on OPAC with SearchEngine syspref set to both Elasticsearch and Zebra
    I just searched for 'a'
2 - Confirm results with no usage are included
3 - Test with both values of OPACShowUnusedAuthorities
4 - Apply patch
5 - Repeat searches with both engines and syspref settings
6 - Confirm unused authorities not shown in either engine when syspref is "Don't show"
7 - Conifrm unused authorities shown in both engines when syspref is "Show"

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 6 Martin Renvoize 2024-06-28 15:53:28 UTC
Thanks for the quick fix Nick.. all working as expected again now.

Passing QA
Comment 7 Katrin Fischer 2024-07-01 16:58:40 UTC
Pushed for 24.11!

Well done everyone, thank you!