Bug 39757

Summary: Serial enumeration / chronology sorting is broken again in biblio page
Product: Koha Reporter: Baptiste Wojtkowski (bwoj) <baptiste.wojtkowski>
Component: CatalogingAssignee: Baptiste Wojtkowski (bwoj) <baptiste.wojtkowski>
Status: Needs Signoff --- QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: fridolin.somers, jonathan.druart, m.de.rooy
Version: MainKeywords: regression
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28171
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:
Bug Depends on: 33568    
Bug Blocks:    
Attachments: Bug 39757: Fix default sort order

Description Baptiste Wojtkowski (bwoj) 2025-04-28 08:45:06 UTC
In biblio page, subscription sorting is broken again :)
Comment 1 Katrin Fischer 2025-04-28 08:46:54 UTC
Can you explain a bit more?
Comment 2 Baptiste Wojtkowski (bwoj) 2025-04-28 08:54:15 UTC
Created attachment 181577 [details] [review]
Bug 39757: Fix default sort order

Test plan:
1 - Have a notice with mutliple serials received on different days, notice
  they are not sorted by date by default
2 - Have a non-serial notice, notice there is no sort order
3 - Apply patch
4 - Go to the serials notice ->  it is well ordered (by acquisition date)
5 - Go to the non-serial notice -> is is sorted by accession date

Note: I picked accession date because it is how it works in
Koha::Item::search_ordered which is not used anymore for this purpose.
Comment 3 Jonathan Druart 2025-04-28 11:01:31 UTC
Is this related to this FIXME in 
Koha/REST/V1/Biblios.pm
+        # FIXME We need to order_by serial.publisheddate if we have _order_by=+me.serial_issue_number

Isn't it something we need server-side instead?
Comment 4 Baptiste Wojtkowski (bwoj) 2025-04-28 11:59:01 UTC
(In reply to Jonathan Druart from comment #3)
> Is this related to this FIXME in 
> Koha/REST/V1/Biblios.pm
> +        # FIXME We need to order_by serial.publisheddate if we have
> _order_by=+me.serial_issue_number
> 
> Isn't it something we need server-side instead?

Hum... I'd rather say both ? If we only fix on server side, the information of the sort order won't be displayed to the user, will it ?

I'd rather say the API stays simple and stupid and we sort as we want on client side, but this comment is there, you're right.
Comment 5 Jonathan Druart 2025-04-28 13:13:30 UTC
What about serialid.publisheddate vs dateaccessioned?

I don't remember exactly but I would look at how it was done before bug 33568.

I cannot right now, but I can have another look later. I would also ask Katrin and/or Nick.
Comment 6 Baptiste Wojtkowski (bwoj) 2025-04-28 14:59:28 UTC
Idk if this helps, but in Koha::Items::search_ordered, it is : serialid.publisheddate > me.enumchron for serials and homebranch.branchname > me.enumchron > me.dateaccessioned (desc) for others