Bug 24366 - Merging biblioitems should happen in Koha::Biblio->to_api
Summary: Merging biblioitems should happen in Koha::Biblio->to_api
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: REST API (show other bugs)
Version: master
Hardware: All All
: P5 - low normal (vote)
Assignee: Tomás Cohen Arazi
QA Contact:
URL:
Keywords:
Depends on: 24228
Blocks: 20212 24554
  Show dependency treegraph
 
Reported: 2020-01-07 15:11 UTC by Tomás Cohen Arazi
Modified: 2020-11-30 21:45 UTC (History)
1 user (show)

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


Attachments
Bug 24366: Unit tests (1.18 KB, patch)
2020-01-07 17:46 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 24366: Merge biblioitem in Koha::Biblio->to_api (3.33 KB, patch)
2020-01-07 17:46 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 24366: Unit tests (1.25 KB, patch)
2020-01-07 19:48 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 24366: Merge biblioitem in Koha::Biblio->to_api (3.40 KB, patch)
2020-01-07 19:48 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 24366: Unit tests (1.31 KB, patch)
2020-01-13 14:16 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 24366: Merge biblioitem in Koha::Biblio->to_api (3.45 KB, patch)
2020-01-13 14:16 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 24366: Improve hashref construction (863 bytes, patch)
2020-01-13 14:16 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 24366: Make sure accessors are used on the right object (2.38 KB, patch)
2020-01-13 19:48 UTC, Tomás Cohen Arazi
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 2020-01-07 15:11:59 UTC
Now we can embed objects, we need to make sure the JSON representation of a biblio object (which includes information from biblioitems) is generated in Koha::Biblio->to_api instead of the API controller.
Comment 1 Tomás Cohen Arazi 2020-01-07 17:46:05 UTC
Created attachment 96914 [details] [review]
Bug 24366: Unit tests
Comment 2 Tomás Cohen Arazi 2020-01-07 17:46:19 UTC
Created attachment 96915 [details] [review]
Bug 24366: Merge biblioitem in Koha::Biblio->to_api

This patch moves the bilbioitem object merge into the
Koha::Biblio->to_api method, as opposed to doing it in the controller.
This is an inevitable change as other endpoints might require to embed
biblio objects, and they need to carry the biblioitem information.

Also, if we merge the tables, the transition will be straightforward
(remove the tests this patch introduces, and merge the mappings from
Koha::Biblioitem into Koha::Biblio).

To test:
1. Apply this patches
2. Run:
   $ kshell
  k$ prove t/db_dependent/Koha/Biblio.t \
           t/db_dependent/api/v1/biblios.t
=> SUCCESS: Tests pass! i.e. the new to_api method is tested, and the
API tests don't expect any behavior change.
3. Sign off :-D
Comment 3 Kyle M Hall 2020-01-07 19:48:35 UTC
Created attachment 96958 [details] [review]
Bug 24366: Unit tests

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 4 Kyle M Hall 2020-01-07 19:48:50 UTC
Created attachment 96959 [details] [review]
Bug 24366: Merge biblioitem in Koha::Biblio->to_api

This patch moves the bilbioitem object merge into the
Koha::Biblio->to_api method, as opposed to doing it in the controller.
This is an inevitable change as other endpoints might require to embed
biblio objects, and they need to carry the biblioitem information.

Also, if we merge the tables, the transition will be straightforward
(remove the tests this patch introduces, and merge the mappings from
Koha::Biblioitem into Koha::Biblio).

To test:
1. Apply this patches
2. Run:
   $ kshell
  k$ prove t/db_dependent/Koha/Biblio.t \
           t/db_dependent/api/v1/biblios.t
=> SUCCESS: Tests pass! i.e. the new to_api method is tested, and the
API tests don't expect any behavior change.
3. Sign off :-D

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 5 Jonathan Druart 2020-01-13 14:16:44 UTC
Created attachment 97312 [details] [review]
Bug 24366: Unit tests

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 6 Jonathan Druart 2020-01-13 14:16:47 UTC
Created attachment 97313 [details] [review]
Bug 24366: Merge biblioitem in Koha::Biblio->to_api

This patch moves the bilbioitem object merge into the
Koha::Biblio->to_api method, as opposed to doing it in the controller.
This is an inevitable change as other endpoints might require to embed
biblio objects, and they need to carry the biblioitem information.

Also, if we merge the tables, the transition will be straightforward
(remove the tests this patch introduces, and merge the mappings from
Koha::Biblioitem into Koha::Biblio).

To test:
1. Apply this patches
2. Run:
   $ kshell
  k$ prove t/db_dependent/Koha/Biblio.t \
           t/db_dependent/api/v1/biblios.t
=> SUCCESS: Tests pass! i.e. the new to_api method is tested, and the
API tests don't expect any behavior change.
3. Sign off :-D

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 7 Jonathan Druart 2020-01-13 14:16:51 UTC
Created attachment 97314 [details] [review]
Bug 24366: Improve hashref construction

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 8 Tomás Cohen Arazi 2020-01-13 19:48:22 UTC
Created attachment 97332 [details] [review]
Bug 24366: Make sure accessors are used on the right object

This patch makes the Koha::Biblio->to_api method try the accessors on
$self first, and fallback to $self->biblioitem on those he can't.

This way it won't happen that (for example) ->holds will be tried
against ->biblioitem.

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

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 9 Martin Renvoize 2020-01-14 14:13:17 UTC
Nice work everyone!

Pushed to master for 20.05
Comment 10 Joy Nelson 2020-01-31 23:14:49 UTC
Does not apply to 19.11.x branch.  Please rebase if needed for 19.11.x
Comment 11 Joy Nelson 2020-03-05 00:26:21 UTC
not pushed to 19.11.x due to dependencies