[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
Tue Jan 28 20:30:44 CET 2020
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24528
--- Comment #2 from Tomás Cohen Arazi <tomascohen at gmail.com> ---
Created attachment 98047
-->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=98047&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
--
You are receiving this mail because:
You are watching all bug changes.
More information about the Koha-bugs
mailing list