https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42587

--- Comment #3 from Tomás Cohen Arazi (tcohen) <[email protected]> ---
Created attachment 199494
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=199494&action=edit
Bug 42587: Make overdues+count sortable via coderef subquery

Extends _build_count_subquery to handle DBIC coderef conditions.
When a relationship uses a coderef (like overdues with date_due < NOW()),
the function invokes it and parses the returned hashref into SQL WHERE
clauses for the COUNT subquery.

Supported condition types:
- -ident (FK join columns)
- Comparison operators (<, >, !=, etc.) with literal SQL or values
- undef (IS NULL)
- -in with scalar ref (literal SQL subquery)

Adds a full-stack API test proving overdues+count sorting works with
patrons having different mixes of overdue and non-overdue checkouts.

Test plan:
1. Apply patches (requires bug 41950)
2. Run:
   $ ktd --shell
   k$ prove t/Koha/REST/Plugin/Query.t \
       t/db_dependent/api/v1/patrons.t \
       t/db_dependent/Koha/Patron.t
=> SUCCESS: All tests pass
3. Verify overdues+count sorting:
   GET /api/v1/patrons
   x-koha-embed: overdues+count
   _order_by: -me.overdues_count
=> SUCCESS: Patrons sorted by overdue count (filtered, not all checkouts)
4. Sign off :-D

Assisted-by: Sonnet 4.6 (Anthropic)

-- 
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/

Reply via email to