Bug 38224 - Move populate_empty_callnumbers logic into Koha::Biblio for reusability
Summary: Move populate_empty_callnumbers logic into Koha::Biblio for reusability
Status: Signed Off
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: Tomás Cohen Arazi (tcohen)
QA Contact: Testopia
URL:
Keywords:
Depends on: 38226
Blocks:
  Show dependency treegraph
 
Reported: 2024-10-22 11:42 UTC by Tomás Cohen Arazi (tcohen)
Modified: 2024-11-07 14:47 UTC (History)
1 user (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Bug 38224: Unit tests (4.14 KB, patch)
2024-10-22 12:45 UTC, Tomás Cohen Arazi (tcohen)
Details | Diff | Splinter Review
Bug 38224: Add Koha::Biblio::populate_item_callnumbers (4.73 KB, patch)
2024-10-22 12:45 UTC, Tomás Cohen Arazi (tcohen)
Details | Diff | Splinter Review
Bug 38224: (follow-up) Rewrite endpoint using new core methods (5.74 KB, patch)
2024-10-22 12:45 UTC, Tomás Cohen Arazi (tcohen)
Details | Diff | Splinter Review
Bug 38224: Unit tests (4.19 KB, patch)
2024-11-07 14:47 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review
Bug 38224: Add Koha::Biblio::populate_item_callnumbers (4.79 KB, patch)
2024-11-07 14:47 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review
Bug 38224: (follow-up) Rewrite endpoint using new core methods (5.79 KB, patch)
2024-11-07 14:47 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
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>