Bug 34587: Remove counter files from API embedding to improve performance
[koha.git] / Koha / REST / V1 / ERM / EUsage / CounterLogs.pm
1 package Koha::REST::V1::ERM::EUsage::CounterLogs;
2
3 # Copyright 2023 PTFS Europe
4
5 # This file is part of Koha.
6 #
7 # Koha is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
11 #
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20 use Modern::Perl;
21
22 use Mojo::Base 'Mojolicious::Controller';
23
24 use Koha::ERM::EUsage::CounterLogs;
25
26 use Scalar::Util qw( blessed );
27 use Try::Tiny    qw( catch try );
28
29 =head1 API
30
31 =head2 Methods
32
33 =head3 list
34
35 =cut
36
37 sub list {
38     my $c = shift->openapi->valid_input or return;
39
40     return try {
41         my $counter_logs_set = Koha::ERM::EUsage::CounterLogs->new;
42         my $counter_logs     = $c->objects->search($counter_logs_set);
43         return $c->render( status => 200, openapi => $counter_logs );
44     } catch {
45         $c->unhandled_exception($_);
46     };
47 }
48
49 1;