Koha-clms/Koha/ILL
Tomás Cohen Arazi 713c5c3343
Bug 41950: (follow-up) Add DBIC relationship aliases for +count embeds
Adds DBIC relationship aliases so that +count embeds advertised in
the API specs are backed by actual database relationships, making
them sortable via the SQL COUNT subquery infrastructure.

New aliases:
- Borrower: checkouts (issues)
- Aqbookseller: baskets (aqbaskets), invoices (aqinvoices)
- Ticket: updates (ticket_updates)
- ErmEholdingsPackage: resources (erm_eholdings_resources)
- Biblio: holds (reserves)

Koha methods are updated to use the new relationship names directly,
following the one-liner style: Koha::Foo->_new_from_dbic( scalar ... )

Note: checkouts on Borrower and subscriptions on Aqbookseller already
had matching DBIC relationships. comments on Illrequest, requests on
IllBatch, and items on Biblio also already existed.

Test plan:
1. Apply patch
2. Run:
   $ ktd --shell
   k$ prove t/Koha/REST/Plugin/Query.t \
       t/db_dependent/api/v1/patrons.t \
       t/db_dependent/api/v1/acquisitions_vendors.t \
       t/db_dependent/Koha/REST/Plugin/Objects.t \
       t/db_dependent/Koha/Biblio.t
=> SUCCESS: All tests pass
3. Verify sorting works:
   GET /api/v1/patrons
   x-koha-embed: checkouts+count
   _order_by: -me.checkouts_count
=> SUCCESS: Patrons sorted by checkout count
4. Sign off :-D

Assisted-by: Sonnet 4.6 (Anthropic)
Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
2026-06-29 16:19:49 +00:00
..
Backend Bug 40105: Patrons cannot add notes when creating an ILL 2026-03-05 08:33:32 -07:00
Batch Bug 42397: Add 'ILL_BATCHES' action_logs modulename 2026-06-19 12:00:16 +00:00
ISO18626 Bug 37762: (QA follow-up): Warn and return 500 on schema validation failure in progress_request 2026-05-15 08:11:12 -06:00
Request Bug 40504: Auto functionality: 2026-03-26 14:21:22 +01:00
Backend.pm Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
Batch.pm Bug 41950: (follow-up) Add DBIC relationship aliases for +count embeds 2026-06-29 16:19:49 +00:00
Batches.pm Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
Comment.pm Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
Comments.pm Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
ISO18626.pm Bug 37762: (QA follow-up): Add ShippedReturn support action type 2026-05-08 12:25:49 -06:00
Request.pm Bug 40504: (QA follow-up) Fix QA script failures 2026-03-26 14:21:25 +01:00
Requests.pm Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00