Summary: | Add Koha::Biblio->items_count | ||
---|---|---|---|
Product: | Koha | Reporter: | Tomás Cohen Arazi <tomascohen> |
Component: | Architecture, internals, and plumbing | Assignee: | Tomás Cohen Arazi <tomascohen> |
Status: | CLOSED FIXED | QA Contact: | Testopia <testopia> |
Severity: | enhancement | ||
Priority: | P5 - low | CC: | 1joynelson, agustinmoyano, jonathan.druart, kyle, liz, martin.renvoize, nick |
Version: | Main | ||
Hardware: | All | ||
OS: | All | ||
See Also: | https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24448 | ||
Change sponsored?: | --- | Patch complexity: | --- |
Documentation contact: | Documentation submission: | ||
Text to go in the release notes: | Version(s) released in: |
20.05.00
|
|
Bug Depends on: | 24430 | ||
Bug Blocks: | 20212, 24467 | ||
Attachments: |
Bug 24435: Unit tests
Bug 24435: Add Koha::Biblio->items_count Bug 24435: Unit tests Bug 24435: Add Koha::Biblio->items_count Bug 24435: Unit tests Bug 24435: Add Koha::Biblio->items_count |
Description
Tomás Cohen Arazi
2020-01-16 16:31:41 UTC
Created attachment 97462 [details] [review] Bug 24435: Unit tests Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Created attachment 97463 [details] [review] Bug 24435: Add Koha::Biblio->items_count This patch introduces a handy shortcut to get the items count for a biblio. So instead of calling: $count = $biblio->items->count; you can call: $count = $biblio->items_count; The use case for this, is when we want to embed information on objects to be sent as API responses. In that case, calling ->items->count needs to be done manually on the controller script, with interesting added complexity. With this kind of method, we can just require it to be embedded automagically by calling the following on the API: $biblio->to_api({ embed => { items_count => {} } }); If there are several nested layers of objects, doing manually can get really tricky and error prone. To test: 1. Apply this patches 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> Created attachment 97489 [details] [review] Bug 24435: Unit tests Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: David Nind <david@davidnind.com> Created attachment 97490 [details] [review] Bug 24435: Add Koha::Biblio->items_count This patch introduces a handy shortcut to get the items count for a biblio. So instead of calling: $count = $biblio->items->count; you can call: $count = $biblio->items_count; The use case for this, is when we want to embed information on objects to be sent as API responses. In that case, calling ->items->count needs to be done manually on the controller script, with interesting added complexity. With this kind of method, we can just require it to be embedded automagically by calling the following on the API: $biblio->to_api({ embed => { items_count => {} } }); If there are several nested layers of objects, doing manually can get really tricky and error prone. To test: 1. Apply this patches 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> Signed-off-by: David Nind <david@davidnind.com> Created attachment 97561 [details] [review] Bug 24435: Unit tests Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Nick Clemens <nick@bywatersolutions.com> Created attachment 97562 [details] [review] Bug 24435: Add Koha::Biblio->items_count This patch introduces a handy shortcut to get the items count for a biblio. So instead of calling: $count = $biblio->items->count; you can call: $count = $biblio->items_count; The use case for this, is when we want to embed information on objects to be sent as API responses. In that case, calling ->items->count needs to be done manually on the controller script, with interesting added complexity. With this kind of method, we can just require it to be embedded automagically by calling the following on the API: $biblio->to_api({ embed => { items_count => {} } }); If there are several nested layers of objects, doing manually can get really tricky and error prone. To test: 1. Apply this patches 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> Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Nick Clemens <nick@bywatersolutions.com> Nice work everyone! Pushed to master for 20.05 enhancement not backported to 19.11.x |