[Koha-bugs] [Bug 24528] Add a syntax for specifying counts on x-koha-embed

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Fri Jan 31 07:36:55 CET 2020


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24528

David Nind <david at davidnind.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #98047|0                           |1
        is obsolete|                            |

--- Comment #7 from David Nind <david at davidnind.com> ---
Created attachment 98200
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=98200&action=edit
Bug 24528: Add *_count support to to_api

This patch adds a way to tell to_api an attribute needs to be calculated
as the count on an existing method/relationship result. For example, if
we wanted to include the holds_count attribute for a Koha::Patron
object, we would call it:

    $ patron_json = $patron->to_api({ embed => { holds_count => { is_count => 1
} } });

This way to_api will internally call

    $json->{holds_count} = $self->holds->count;

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

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

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list