The metadata() method in the Standard ILL backend uses an inefficient pattern for filtering attributes, performing a linear search through an ignore list for every attribute using grep inside a while loop. This approach becomes increasingly slow as the number of attributes grows, and manually iterates through all attributes instead of leveraging database-level filtering.
Created attachment 186742 [details] [review] Bug 40856: Add unit tests for Standard backend metadata method This patch adds comprehensive unit tests for the metadata() method in the Standard ILL backend to establish baseline behavior before optimization. The tests cover: - Metadata structure (returns hashref) - Included attributes (title, author, isbn, year, custom fields) - Excluded attributes (ignored fields like requested_partners, type, etc.) - Display name transformation (attribute types become display names) Current behavior tested: - metadata() filters out predefined ignore list attributes - Uses linear search with grep for each attribute - Transforms attribute types to display names (title -> Title) - Custom fields get ucfirst transformation (custom_field -> Custom_field) - Returns hashref with display names as keys These tests document the current inefficient implementation and will ensure the upcoming optimization maintains compatibility. Test plan: 1. Apply patch 2. Run: $ ktd --shell k$ prove t/db_dependent/Koha/ILL/Backend/Standard.t => SUCCESS: Tests pass! Current metadata behavior documented 3. Tests establish baseline for upcoming optimization 4. Sign off :-D
Created attachment 186743 [details] [review] Bug 40856: Optimize Standard backend metadata method with database-level filtering This patch optimizes the metadata() method in the Standard ILL backend to use database-level filtering instead of inefficient linear searches. Performance improvement: - Before: Load all attributes, then filter each with linear search - After: Load only relevant attributes using database index Test plan: 1. Apply patch 2. Run: $ ktd --shell k$ prove t/db_dependent/Koha/ILL/Backend/Standard.t => SUCCESS: Tests pass! Optimization maintains compatibility 3. Test ILL request metadata display: - View ILL request details - Verify metadata shows correctly - Check ignored fields are excluded => SUCCESS: Same functionality, better performance 4. Sign off :-D
Created attachment 186760 [details] [review] Bug 40856: Add unit tests for Standard backend metadata method This patch adds comprehensive unit tests for the metadata() method in the Standard ILL backend to establish baseline behavior before optimization. The tests cover: - Metadata structure (returns hashref) - Included attributes (title, author, isbn, year, custom fields) - Excluded attributes (ignored fields like requested_partners, type, etc.) - Display name transformation (attribute types become display names) Current behavior tested: - metadata() filters out predefined ignore list attributes - Uses linear search with grep for each attribute - Transforms attribute types to display names (title -> Title) - Custom fields get ucfirst transformation (custom_field -> Custom_field) - Returns hashref with display names as keys These tests document the current inefficient implementation and will ensure the upcoming optimization maintains compatibility. Test plan: 1. Apply patch 2. Run: $ ktd --shell k$ prove t/db_dependent/Koha/ILL/Backend/Standard.t => SUCCESS: Tests pass! Current metadata behavior documented 3. Tests establish baseline for upcoming optimization 4. Sign off :-D Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Created attachment 186761 [details] [review] Bug 40856: Optimize Standard backend metadata method with database-level filtering This patch optimizes the metadata() method in the Standard ILL backend to use database-level filtering instead of inefficient linear searches. Performance improvement: - Before: Load all attributes, then filter each with linear search - After: Load only relevant attributes using database index Test plan: 1. Apply patch 2. Run: $ ktd --shell k$ prove t/db_dependent/Koha/ILL/Backend/Standard.t => SUCCESS: Tests pass! Optimization maintains compatibility 3. Test ILL request metadata display: - View ILL request details - Verify metadata shows correctly - Check ignored fields are excluded => SUCCESS: Same functionality, better performance 4. Sign off :-D Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Simple internal API improvement, well covered by tests. Straight for QA, Passed.
Nice work everyone! Pushed to main for 25.11