Bug 24219

Summary: Elasticsearch needs to remember sort preference when returning to result list
Product: Koha Reporter: Myka Kennedy Stephens <mkstephens>
Component: SearchingAssignee: Jonathan Druart <jonathan.druart>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low CC: 1joynelson, aspencatteam, black23, jonathan.druart, lucas, martin.renvoize
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
20.05.00
Attachments: Bug 24219: Preserve sort order when returning to result list
Bug 24219: Preserve sort order when returning to result list
Bug 24219: Preserve sort order when returning to result list
Bug 24219: Preserve sort order when returning to result list
Bug 24219: Preserve sort order when returning to result list

Description Myka Kennedy Stephens 2019-12-11 18:57:22 UTC
At the present, the sort preference applied to a list of results in the staff client is not remembered when the user returns to the result list after viewing a record. Ideally, clicking on the button to return to the result list should remember the sort preference selected prior to viewing a record.

Steps to replicate:
1. Have Elasticsearch enabled
2. Perform a search in the staff client
3. Change the sort order to something different (try Author A-Z)
4. Click on a result to view the record
5. Click on "Results" button on left side to return to result list
6. Note that the result list is sorted by relevancy again and not call number

Note: On master, the OPAC remembers sort order in both the "browse results" and "back to results" link.
Comment 1 Jonathan Druart 2019-12-17 09:46:29 UTC
This impacts both Zebra and Elasticsearch
Comment 2 Jonathan Druart 2019-12-17 09:49:58 UTC
Created attachment 96359 [details] [review]
Bug 24219: Preserve sort order when returning to result list

There is a mismatch between sort_cgi, sort and sort_by variables.

 * sort_cgi
I did not find relevant occurrences of sort_cgi in the git log of both
search.pl and results.tt. So it seems that it never worked correctly.
 * sort
It is the JS variable use in browser.js
 * sort_by is the search.pl parameter to set the sort_by option

Test plan:
1. Perform a search in the staff client
2. Change the sort order to something different (try Author A-Z)
3. Click on a result to view the record
4. Click on "Results" button on left side to return to result list
=> Without this patch the result list is sorted by relevancy
=> With this patch applied the Author A-Z is kept
Comment 3 Lucas Gass 2019-12-17 18:11:48 UTC
Created attachment 96390 [details] [review]
Bug 24219: Preserve sort order when returning to result list

There is a mismatch between sort_cgi, sort and sort_by variables.

 * sort_cgi
I did not find relevant occurrences of sort_cgi in the git log of both
search.pl and results.tt. So it seems that it never worked correctly.
 * sort
It is the JS variable use in browser.js
 * sort_by is the search.pl parameter to set the sort_by option

Test plan:
1. Perform a search in the staff client
2. Change the sort order to something different (try Author A-Z)
3. Click on a result to view the record
4. Click on "Results" button on left side to return to result list
=> Without this patch the result list is sorted by relevancy
=> With this patch applied the Author A-Z is kept

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Comment 4 Martin Renvoize 2020-02-24 12:24:45 UTC
Sorry Jonathan, this one needs a rebase.
Comment 5 Jonathan Druart 2020-02-24 12:54:01 UTC
Created attachment 99512 [details] [review]
Bug 24219: Preserve sort order when returning to result list

There is a mismatch between sort_cgi, sort and sort_by variables.

 * sort_cgi
I did not find relevant occurrences of sort_cgi in the git log of both
search.pl and results.tt. So it seems that it never worked correctly.
 * sort
It is the JS variable use in browser.js
 * sort_by is the search.pl parameter to set the sort_by option

Test plan:
1. Perform a search in the staff client
2. Change the sort order to something different (try Author A-Z)
3. Click on a result to view the record
4. Click on "Results" button on left side to return to result list
=> Without this patch the result list is sorted by relevancy
=> With this patch applied the Author A-Z is kept
Comment 6 Michal Denar 2020-03-01 22:54:03 UTC
Created attachment 99847 [details] [review]
Bug 24219: Preserve sort order when returning to result list

There is a mismatch between sort_cgi, sort and sort_by variables.

 * sort_cgi
I did not find relevant occurrences of sort_cgi in the git log of both
search.pl and results.tt. So it seems that it never worked correctly.
 * sort
It is the JS variable use in browser.js
 * sort_by is the search.pl parameter to set the sort_by option

Test plan:
1. Perform a search in the staff client
2. Change the sort order to something different (try Author A-Z)
3. Click on a result to view the record
4. Click on "Results" button on left side to return to result list
=> Without this patch the result list is sorted by relevancy
=> With this patch applied the Author A-Z is kept

Signed-off-by: Michal Denar <black23@gmail.com>
Comment 7 Nick Clemens 2020-03-06 11:56:51 UTC
Created attachment 100266 [details] [review]
Bug 24219: Preserve sort order when returning to result list

There is a mismatch between sort_cgi, sort and sort_by variables.

 * sort_cgi
I did not find relevant occurrences of sort_cgi in the git log of both
search.pl and results.tt. So it seems that it never worked correctly.
 * sort
It is the JS variable use in browser.js
 * sort_by is the search.pl parameter to set the sort_by option

Test plan:
1. Perform a search in the staff client
2. Change the sort order to something different (try Author A-Z)
3. Click on a result to view the record
4. Click on "Results" button on left side to return to result list
=> Without this patch the result list is sorted by relevancy
=> With this patch applied the Author A-Z is kept

Signed-off-by: Michal Denar <black23@gmail.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 8 Martin Renvoize 2020-03-06 15:02:39 UTC
Nice work everyone!

Pushed to master for 20.05
Comment 9 Joy Nelson 2020-04-02 16:22:47 UTC
does not apply to 19.11.x branch.  please rebase if needed.