Bug 24554

Summary: Only embed relations from Koha::Biblio in to_api
Product: Koha Reporter: Tomás Cohen Arazi <tomascohen>
Component: REST APIAssignee: Tomás Cohen Arazi <tomascohen>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P5 - low CC: 1joynelson
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
20.05.00
Bug Depends on: 24366, 24528    
Bug Blocks: 20212    
Attachments: Bug 24554: Only embed relations from Koha::Biblio in to_api
Bug 24554: Only embed relations from Koha::Biblio in to_api
Bug 24554: Only embed relations from Koha::Biblio in to_api

Description Tomás Cohen Arazi 2020-01-31 12:05:00 UTC
The current implemented behaviour of this method (fallback to the biblioitems relations) breaks using it with bug 24538. On fixing it, I noticed the method is quite over-engineered.

As biblioitems is not a real entity on the API and we are not going to add related tables to bilbioitems (most probably get it merged into biblio) we don't need the pass-through of embeds into the biblioitem object.

This makes counts work, and also makes sense :-D
Comment 1 Tomás Cohen Arazi 2020-01-31 12:11:20 UTC
Created attachment 98225 [details] [review]
Bug 24554: Only embed relations from Koha::Biblio in to_api

This patch simplifies the behaviour of Koha::Biblio->to_api. It was
designed with the idea of handling possible methods that would be added
to Koha::Biblioitem. But it had a weird fallback behaviour was
highlighted by using it with bug 24528.

On fixing it it become obvious that it was unnessessarily complex and
that it was not worth. That's the reason there wasn't any test for it,
as Koha::Biblioitem doesn't implement any extra methods.

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

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 2 David Nind 2020-02-01 20:23:22 UTC
Created attachment 98266 [details] [review]
Bug 24554: Only embed relations from Koha::Biblio in to_api

This patch simplifies the behaviour of Koha::Biblio->to_api. It was
designed with the idea of handling possible methods that would be added
to Koha::Biblioitem. But it had a weird fallback behaviour was
highlighted by using it with bug 24528.

On fixing it it become obvious that it was unnessessarily complex and
that it was not worth. That's the reason there wasn't any test for it,
as Koha::Biblioitem doesn't implement any extra methods.

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

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: David Nind <david@davidnind.com>
Comment 3 Jonathan Druart 2020-02-06 09:19:22 UTC
Created attachment 98519 [details] [review]
Bug 24554: Only embed relations from Koha::Biblio in to_api

This patch simplifies the behaviour of Koha::Biblio->to_api. It was
designed with the idea of handling possible methods that would be added
to Koha::Biblioitem. But it had a weird fallback behaviour was
highlighted by using it with bug 24528.

On fixing it it become obvious that it was unnessessarily complex and
that it was not worth. That's the reason there wasn't any test for it,
as Koha::Biblioitem doesn't implement any extra methods.

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

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 4 Martin Renvoize 2020-02-06 12:38:01 UTC
Nice work everyone!

Pushed to master for 20.05
Comment 5 Joy Nelson 2020-03-05 00:25:51 UTC
Not pushed to 19.11.x due to dependencies