Bug 38224

Summary: Move populate_empty_callnumbers logic into Koha::Biblio for reusability
Product: Koha Reporter: Tomás Cohen Arazi (tcohen) <tomascohen>
Component: Architecture, internals, and plumbingAssignee: Tomás Cohen Arazi (tcohen) <tomascohen>
Status: Signed Off --- QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: tomascohen
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:
Bug Depends on: 38226    
Bug Blocks:    
Attachments: Bug 38224: Unit tests
Bug 38224: Add Koha::Biblio::populate_item_callnumbers
Bug 38224: (follow-up) Rewrite endpoint using new core methods
Bug 38224: Unit tests
Bug 38224: Add Koha::Biblio::populate_item_callnumbers
Bug 38224: (follow-up) Rewrite endpoint using new core methods

Description Tomás Cohen Arazi (tcohen) 2024-10-22 11:42:23 UTC
Bug 34784 introduced an endpoint for populating empty item callnumbers.
In order to be able to create a CLI script for the same purpose, it would be positive to migrate that code into Koha::Biblio.
Comment 1 Tomás Cohen Arazi (tcohen) 2024-10-22 12:45:20 UTC
Created attachment 173134 [details] [review]
Bug 38224: Unit tests
Comment 2 Tomás Cohen Arazi (tcohen) 2024-10-22 12:45:22 UTC
Created attachment 173135 [details] [review]
Bug 38224: Add Koha::Biblio::populate_item_callnumbers

This patch introduces two methods to the `Koha::Biblio` class:

* `get_first_callnumber`: returns the first found callnumber on the
  record, based on the `itemcallnumber` syspref.
* `populate_item_callnumbers`: populates the bibliographic record's
  items based on the return value of `get_first_callnumber`. Can be
  passed a filter on the items.

To test:
1. Apply this patch
2. Run:
   $ ktd --shell
  k$ prove t/db_dependent/Koha/Biblio.t
=> SUCCESS: Tests pass!
3. Sign off :-D
Comment 3 Tomás Cohen Arazi (tcohen) 2024-10-22 12:45:25 UTC
Created attachment 173136 [details] [review]
Bug 38224: (follow-up) Rewrite endpoint using new core methods

Now we have core methods, we can use them to rewrite the controller.

Behavior should remain unchanged, so to test:

1. Apply this patches
2. Run:
   $ ktd --shell
  k$ prove t/db_dependent/api/v1/rpc/biblios.t
=> SUCCESS: tests pass!
3. Sign off :-D
Comment 4 Nick Clemens (kidclamp) 2024-11-07 14:47:30 UTC
Created attachment 174244 [details] [review]
Bug 38224: Unit tests

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 5 Nick Clemens (kidclamp) 2024-11-07 14:47:31 UTC
Created attachment 174245 [details] [review]
Bug 38224: Add Koha::Biblio::populate_item_callnumbers

This patch introduces two methods to the `Koha::Biblio` class:

* `get_first_callnumber`: returns the first found callnumber on the
  record, based on the `itemcallnumber` syspref.
* `populate_item_callnumbers`: populates the bibliographic record's
  items based on the return value of `get_first_callnumber`. Can be
  passed a filter on the items.

To test:
1. Apply this patch
2. Run:
   $ ktd --shell
  k$ prove t/db_dependent/Koha/Biblio.t
=> SUCCESS: Tests pass!
3. Sign off :-D

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 6 Nick Clemens (kidclamp) 2024-11-07 14:47:33 UTC
Created attachment 174246 [details] [review]
Bug 38224: (follow-up) Rewrite endpoint using new core methods

Now we have core methods, we can use them to rewrite the controller.

Behavior should remain unchanged, so to test:

1. Apply this patches
2. Run:
   $ ktd --shell
  k$ prove t/db_dependent/api/v1/rpc/biblios.t
=> SUCCESS: tests pass!
3. Sign off :-D

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>