https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42587
Bug ID: 42587
Summary: overdues+count is not sortable on the API
Initiative type: ---
Sponsorship ---
status:
Product: Koha
Version: Main
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P5 - low
Component: REST API
Assignee: [email protected]
Reporter: [email protected]
QA Contact: [email protected]
CC: [email protected]
Depends on: 41950
The overdues+count embed on the patrons endpoint cannot be sorted because the
overdues DBIC relationship does not exist on the Borrower result class.
The Koha::Patron->overdues method currently filters checkouts in Perl (date_due
< NOW()). To make it sortable, we need:
1. A DBIC coderef relationship on Borrower that filters issues.date_due < NOW()
at the SQL level
2. Teach _build_count_subquery to handle coderef conditions (invoke the
coderef, parse the returned hashref into WHERE clauses)
3. Update Koha::Patron->overdues to delegate to the DBIC relationship
4. Unit tests proving the sort works with a mix of overdue and non-overdue
checkouts
The generated subquery would be:
(SELECT COUNT(*) FROM issues WHERE issues.borrowernumber = me.borrowernumber
AND issues.date_due < NOW())
Test plan:
prove t/Koha/REST/Plugin/Query.t t/db_dependent/api/v1/patrons.t
t/db_dependent/Koha/Patron.t
Referenced Bugs:
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41950
[Bug 41950] Make +count embeds sortable by using SQL-level COUNT subqueries
--
You are receiving this mail because:
You are the assignee for the bug.
You are watching all bug changes.
_______________________________________________
Koha-bugs mailing list
[email protected]
https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-bugs
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/