@@ -, +, @@ $ kshell k$ prove t/Koha/REST/Plugin/Query.t --- Koha/REST/Plugin/Query.pm | 8 +++++++- t/Koha/REST/Plugin/Query.t | 9 +++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) --- a/Koha/REST/Plugin/Query.pm +++ a/Koha/REST/Plugin/Query.pm @@ -263,7 +263,13 @@ sub _parse_embed { $result->{$curr} = { children => _parse_embed( $next ) }; } else { - $result->{$curr} = {}; + if ( $curr =~ m/^(?.*)\+count/ ) { + my $key = $+{relation} . "_count"; + $result->{$key} = { is_count => 1 }; + } + else { + $result->{$curr} = {}; + } } return $result; --- a/t/Koha/REST/Plugin/Query.t +++ a/t/Koha/REST/Plugin/Query.t @@ -140,7 +140,8 @@ get '/stash_embed' => sub { 'x-koha-embed' => [ 'checkouts', 'checkouts.item', - 'library' + 'library', + 'holds+count' ] } } @@ -304,7 +305,7 @@ subtest '_build_query_params_from_api' => sub { subtest 'stash_embed() tests' => sub { - plan tests => 12; + plan tests => 15; my $t = Test::Mojo->new; @@ -316,6 +317,10 @@ subtest 'stash_embed() tests' => sub { ->status_is(200) ->json_is( { checkouts => { children => { item => {} } }, library => {} } ); + $t->get_ok( '/stash_embed' => { 'x-koha-embed' => 'holds+count' } ) + ->status_is(200) + ->json_is( { holds_count => { is_count => 1 } } ); + $t->get_ok( '/stash_embed' => { 'x-koha-embed' => 'checkouts,checkouts.item,patron' } ) ->status_is(400) ->json_is( --