[Bug 42589] New: bundle_items_lost+count is not sortable on the API
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: koha-bugs@lists.koha-community.org Reporter: tomascohen@gmail.com QA Contact: testopia@bugs.koha-community.org CC: tomascohen@gmail.com 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.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42589 Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Depends on| |42587 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42587 [Bug 42587] overdues+count is not sortable on the API -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42589 Bug 42589 depends on bug 41950, which changed state. Bug 41950 Summary: Make +count embeds sortable by using SQL-level COUNT subqueries https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41950 What |Removed |Added ---------------------------------------------------------------------------- Status|Needs documenting |RESOLVED Resolution|--- |FIXED -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org