https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42589
Bug ID: 42589
Summary: bundle_items_lost+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 bundle_items_lost+count embed on the biblio items endpoint cannot be sorted
because the bundle_items_lost DBIC relationship does not exist on the Item
result class.
The Koha::Item->bundle_items_lost method currently uses a many_to_many accessor
with a Perl-side filter (itemlost != 0). To make it sortable, we need:
1. A DBIC coderef relationship on Item pointing to Koha::Schema::Result::Item
with an -in subquery through the item_bundles bridge table and a filter on
itemlost != 0
2. Support for -in with scalar ref (literal SQL) in _build_count_subquery
3. Update Koha::Item->bundle_items_lost to delegate to the DBIC relationship
4. Unit tests proving the sort works
The generated subquery would be:
(SELECT COUNT(*) FROM items WHERE items.itemnumber IN (SELECT item FROM
item_bundles WHERE host = me.itemnumber) AND items.itemlost != 0)
Performance note: This uses a correlated IN subquery. For large catalogs with
many bundles, this could be slow. An alternative would be a JOIN-based COUNT,
but that requires more complex changes to _build_count_subquery. The trade-off
should be evaluated.
Test plan:
prove t/Koha/REST/Plugin/Query.t t/db_dependent/api/v1/biblios.t
t/db_dependent/Koha/Item.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 watching all bug changes.
You are the assignee for the bug.
_______________________________________________
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/