Bug 39158

Summary: Reduce code duplication in marc_records_to_documents
Product: Koha Reporter: David Gustafsson <glasklas>
Component: Searching - ElasticsearchAssignee: David Gustafsson <glasklas>
Status: Signed Off --- QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: ludovic.julien
Version: unspecified   
Hardware: All   
OS: All   
GIT URL: Initiative type: ---
Sponsorship status: --- Comma delimited list of Sponsors:
Crowdfunding goal: 0 Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:
Attachments: Bug 39158: Reduce code duplication in marc_records_to_documents
Bug 39158: Reduce code duplication in marc_records_to_documents

Description David Gustafsson 2025-02-18 22:53:50 UTC
There is currently a block in Koha::SearchEngine::Elasticsearch::marc_records_to_documents that in my opinion should be brokwn out to its own method for increased maintainability and readability. It's easily done that these two blocks will drift apart with time (when they should be the same), fixing a bug in one place, forgetting in another etc. Here is a patch to fix this.
Comment 1 David Gustafsson 2025-02-18 23:01:25 UTC
Created attachment 178302 [details] [review]
Bug 39158: Reduce code duplication in marc_records_to_documents

Refactor marc_record_to_documents to avoid code duplicaiton.

To test:
1) Verify tests in t/db_dependant/Koha/SearchEngine/Elasticsearch.t all
   pass
2) Apply patch
3) Veriy tests in t/db_dependant/Koha/SearchEngine/Elasticsearch.t
   still pass
Comment 2 Ludovic 2025-09-04 21:36:24 UTC
I tested the patch and all tests in t/db_dependent/Koha/SearchEngine/Elasticsearch.t pass.
Having cleaner code like this is always helpful and appreciated.

Signed-off-by: Ludovic Julien <ludovic.julien@inLibro.com>
Comment 3 David Gustafsson 2025-11-21 08:53:30 UTC
Created attachment 189831 [details] [review]
Bug 39158: Reduce code duplication in marc_records_to_documents

Refactor marc_record_to_documents to avoid code duplicaiton.

To test:
1) Verify tests in t/db_dependant/Koha/SearchEngine/Elasticsearch.t all
   pass
2) Apply patch
3) Veriy tests in t/db_dependant/Koha/SearchEngine/Elasticsearch.t
   still pass
Comment 4 David Gustafsson 2025-11-21 08:54:07 UTC
Rebased against master.