Bug 34587: Move everything into a ERM/EUsage subfolder
Signed-off-by: Jessica Zairo <jzairo@bywatersolutions.com> Signed-off-by: Michaela Sieber <michaela.sieber@kit.edu> Signed-off-by: Nick Clemens <nick@bywatersolutions.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
parent
f32636bbbd
commit
ca8ea02fda
|
|
@ -20,7 +20,7 @@ use Modern::Perl;
|
|||
use Try::Tiny;
|
||||
|
||||
use Koha::DateUtils qw( dt_from_string );
|
||||
use Koha::ERM::UsageDataProviders;
|
||||
use Koha::ERM::EUsage::UsageDataProviders;
|
||||
|
||||
use base 'Koha::BackgroundJob';
|
||||
|
||||
|
|
@ -67,13 +67,12 @@ sub process {
|
|||
added_yus => 0
|
||||
};
|
||||
|
||||
# FIXME If the job has already been started, but started again (worker has been restart for instance)
|
||||
# Then we will start from scratch and so double process the same records
|
||||
# FIXME If the job has already been started, but started again (worker has been restart for instance)
|
||||
# Then we will start from scratch and so double process the same records
|
||||
|
||||
$self->start;
|
||||
|
||||
my $ud_provider =
|
||||
Koha::ERM::UsageDataProviders->find( $args->{ud_provider_id} );
|
||||
my $ud_provider = Koha::ERM::EUsage::UsageDataProviders->find( $args->{ud_provider_id} );
|
||||
|
||||
$ud_provider->set_background_job_callbacks(
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package Koha::ERM::CounterFile;
|
||||
package Koha::ERM::EUsage::CounterFile;
|
||||
|
||||
# Copyright 2023 PTFS Europe
|
||||
|
||||
|
|
@ -21,25 +21,25 @@ use Modern::Perl;
|
|||
|
||||
use Text::CSV_XS qw( csv );
|
||||
|
||||
use Koha::ERM::CounterLog;
|
||||
use Koha::ERM::UsagePlatform;
|
||||
use Koha::ERM::UsagePlatforms;
|
||||
use Koha::ERM::UsageDatabase;
|
||||
use Koha::ERM::UsageDatabases;
|
||||
use Koha::ERM::UsageItem;
|
||||
use Koha::ERM::UsageItems;
|
||||
use Koha::ERM::UsageTitle;
|
||||
use Koha::ERM::UsageTitles;
|
||||
use Koha::ERM::UsageDataProvider;
|
||||
use Koha::Exceptions::ERM::CounterFile;
|
||||
use Koha::ERM::EUsage::CounterLog;
|
||||
use Koha::ERM::EUsage::UsagePlatform;
|
||||
use Koha::ERM::EUsage::UsagePlatforms;
|
||||
use Koha::ERM::EUsage::UsageDatabase;
|
||||
use Koha::ERM::EUsage::UsageDatabases;
|
||||
use Koha::ERM::EUsage::UsageItem;
|
||||
use Koha::ERM::EUsage::UsageItems;
|
||||
use Koha::ERM::EUsage::UsageTitle;
|
||||
use Koha::ERM::EUsage::UsageTitles;
|
||||
use Koha::ERM::EUsage::UsageDataProvider;
|
||||
use Koha::Exceptions::ERM::EUsage::CounterFile;
|
||||
|
||||
use base qw(Koha::Object);
|
||||
|
||||
use Koha::ERM::CounterLogs;
|
||||
use Koha::ERM::EUsage::CounterLogs;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Koha::ERM::CounterFile - Koha ErmCounterFile Object class
|
||||
Koha::ERM::EUsage::CounterFile - Koha ErmCounterFile Object class
|
||||
|
||||
=head1 API
|
||||
|
||||
|
|
@ -57,12 +57,12 @@ sub counter_logs {
|
|||
my ($self) = @_;
|
||||
|
||||
my $counter_logs_rs = $self->_result->erm_counter_logs;
|
||||
return Koha::ERM::CounterLogs->_new_from_dbic($counter_logs_rs);
|
||||
return Koha::ERM::EUsage::CounterLogs->_new_from_dbic($counter_logs_rs);
|
||||
}
|
||||
|
||||
=head3 store
|
||||
|
||||
Koha::ERM::CounterFile->new($counter_file)->store( $self->{job_callbacks} );
|
||||
Koha::ERM::EUsage::CounterFile->new($counter_file)->store( $self->{job_callbacks} );
|
||||
|
||||
Stores the csv COUNTER file.
|
||||
Adds usage titles from the file.
|
||||
|
|
@ -104,7 +104,7 @@ sub get_usage_data_provider {
|
|||
my ($self) = @_;
|
||||
|
||||
my $usage_data_provider = $self->_result->usage_data_provider;
|
||||
return Koha::ERM::UsageDataProvider->_new_from_dbic($usage_data_provider);
|
||||
return Koha::ERM::EUsage::UsageDataProvider->_new_from_dbic($usage_data_provider);
|
||||
}
|
||||
|
||||
=head2 Internal methods
|
||||
|
|
@ -128,30 +128,29 @@ sub _add_usage_objects {
|
|||
|
||||
# Set job size to the amount of rows we're processing
|
||||
$self->{job_callbacks}->{set_size_callback}->( scalar( @{$rows} ) )
|
||||
if $self->{job_callbacks};
|
||||
if $self->{job_callbacks};
|
||||
|
||||
foreach my $row ( @{$rows} ) {
|
||||
|
||||
# INFO: A single row may have multiple instances in the COUNTER report, one for each metric_type or access_type
|
||||
# If we're on a row that we've already gone through, use the same usage object
|
||||
# and add usage statistics for the different metric_type or access_type
|
||||
# INFO: A single row may have multiple instances in the COUNTER report, one for each metric_type or access_type
|
||||
# If we're on a row that we've already gone through, use the same usage object
|
||||
# and add usage statistics for the different metric_type or access_type
|
||||
if ( $self->_is_same_usage_object( $previous_object, $row ) ) {
|
||||
$usage_object = $previous_object;
|
||||
}
|
||||
else {
|
||||
# Update background job step
|
||||
$self->{job_callbacks}->{step_callback}->() if $self->{job_callbacks};
|
||||
} else {
|
||||
|
||||
# Check if usage object already exists in this data provider, e.g. from a previous harvest
|
||||
$usage_object = $self->_search_for_usage_object($row);
|
||||
|
||||
if ($usage_object) {
|
||||
|
||||
# Usage object already exists, add job warning message and do nothing else
|
||||
$self->_add_job_message( 'warning', 'object_already_exists',
|
||||
$row );
|
||||
}
|
||||
else {
|
||||
# Usage object already exists, add job warning message and do nothing else
|
||||
$self->_add_job_message(
|
||||
'warning', 'object_already_exists',
|
||||
$row
|
||||
);
|
||||
} else {
|
||||
|
||||
# Fresh usage object, create it
|
||||
$usage_object = $self->_add_usage_object_entry($row);
|
||||
|
||||
|
|
@ -162,7 +161,7 @@ sub _add_usage_objects {
|
|||
|
||||
# Regex match for Mmm-yyyy expected format, e.g. "Jan 2022"
|
||||
my @date_fields =
|
||||
map( $_ =~ /\b[A-Z][a-z][a-z]\b [0-9]{4}\b/ ? $_ : (), keys %{$row} );
|
||||
map( $_ =~ /\b[A-Z][a-z][a-z]\b [0-9]{4}\b/ ? $_ : (), keys %{$row} );
|
||||
|
||||
unless (@date_fields) {
|
||||
warn "No monthly usage fields retrieved";
|
||||
|
|
@ -181,18 +180,21 @@ sub _add_usage_objects {
|
|||
|
||||
if ( !exists $yearly_usages{$year} ) {
|
||||
$yearly_usages{$year} = $usage;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$yearly_usages{$year} += $usage;
|
||||
}
|
||||
|
||||
$self->_add_monthly_usage_entries( $usage_object,
|
||||
$row->{Metric_Type}, $row, $year, $month, $usage );
|
||||
$self->_add_monthly_usage_entries(
|
||||
$usage_object,
|
||||
$row->{Metric_Type}, $row, $year, $month, $usage
|
||||
);
|
||||
}
|
||||
|
||||
# Add yearly usage statistics for this usage object
|
||||
$self->_add_yearly_usage_entries( $usage_object, $row->{Metric_Type},
|
||||
$row, \%yearly_usages );
|
||||
$self->_add_yearly_usage_entries(
|
||||
$usage_object, $row->{Metric_Type},
|
||||
$row, \%yearly_usages
|
||||
);
|
||||
|
||||
$previous_object = $usage_object;
|
||||
|
||||
|
|
@ -212,19 +214,17 @@ sub _add_monthly_usage_entries {
|
|||
|
||||
my $usage_data_provider = $self->get_usage_data_provider;
|
||||
my $usage_object_info = $self->_get_usage_object_id_hash($usage_object);
|
||||
my $specific_fields =
|
||||
$usage_data_provider->get_report_type_specific_fields( $self->type );
|
||||
my $specific_fields = $usage_data_provider->get_report_type_specific_fields( $self->type );
|
||||
|
||||
$usage_object->monthly_usages(
|
||||
[
|
||||
{
|
||||
%{$usage_object_info},
|
||||
usage_data_provider_id =>
|
||||
$usage_data_provider->erm_usage_data_provider_id,
|
||||
year => $year,
|
||||
month => $self->_get_month_number($month),
|
||||
usage_count => $usage,
|
||||
metric_type => $row->{Metric_Type},
|
||||
usage_data_provider_id => $usage_data_provider->erm_usage_data_provider_id,
|
||||
year => $year,
|
||||
month => $self->_get_month_number($month),
|
||||
usage_count => $usage,
|
||||
metric_type => $row->{Metric_Type},
|
||||
grep ( /Access_Type/, @{$specific_fields} )
|
||||
? ( access_type => $row->{Access_Type} )
|
||||
: (),
|
||||
|
|
@ -246,8 +246,7 @@ sub _add_yearly_usage_entries {
|
|||
|
||||
my $usage_data_provider = $self->get_usage_data_provider;
|
||||
my $usage_object_info = $self->_get_usage_object_id_hash($usage_object);
|
||||
my $specific_fields =
|
||||
$usage_data_provider->get_report_type_specific_fields( $self->type );
|
||||
my $specific_fields = $usage_data_provider->get_report_type_specific_fields( $self->type );
|
||||
|
||||
while ( my ( $year, $usage ) = each( %{$yearly_usages} ) ) {
|
||||
|
||||
|
|
@ -258,11 +257,10 @@ sub _add_yearly_usage_entries {
|
|||
[
|
||||
{
|
||||
%{$usage_object_info},
|
||||
usage_data_provider_id =>
|
||||
$usage_data_provider->erm_usage_data_provider_id,
|
||||
year => $year,
|
||||
totalcount => $usage,
|
||||
metric_type => $metric_type,
|
||||
usage_data_provider_id => $usage_data_provider->erm_usage_data_provider_id,
|
||||
year => $year,
|
||||
totalcount => $usage,
|
||||
metric_type => $metric_type,
|
||||
grep ( /Access_Type/, @{$specific_fields} )
|
||||
? ( access_type => $row->{Access_Type} )
|
||||
: (),
|
||||
|
|
@ -278,7 +276,7 @@ sub _add_yearly_usage_entries {
|
|||
|
||||
Verifies if the given file_content is a valid COUNTER file or not
|
||||
|
||||
A I <Koha::Exceptions::ERM::CounterFile> exception is thrown
|
||||
A I <Koha::Exceptions::ERM::EUsage::CounterFile> exception is thrown
|
||||
if the file is invalid .
|
||||
|
||||
=cut
|
||||
|
|
@ -291,14 +289,15 @@ sub validate {
|
|||
|
||||
$csv->column_names(qw( header_key header_value ));
|
||||
my @header_rows = $csv->getline_hr_all( $fh, 0, 12 );
|
||||
my @header = $header_rows[0];
|
||||
my @header = $header_rows[0];
|
||||
|
||||
my @release_row = map( $_->{header_key} eq 'Release' ? $_ : (), @{ $header[0] } );
|
||||
my @release_row =
|
||||
map( $_->{header_key} eq 'Release' ? $_ : (), @{ $header[0] } );
|
||||
my $release = $release_row[0];
|
||||
|
||||
# TODO: Validate that there is an empty row between header and body
|
||||
|
||||
Koha::Exceptions::ERM::CounterFile::UnsupportedRelease->throw
|
||||
Koha::Exceptions::ERM::EUsage::CounterFile::UnsupportedRelease->throw
|
||||
if $release && $release->{header_value} != 5;
|
||||
|
||||
}
|
||||
|
|
@ -319,8 +318,9 @@ sub _set_report_type_from_file {
|
|||
my @header_rows = $csv->getline_hr_all( $fh, 0, 12 );
|
||||
my @header = $header_rows[0];
|
||||
|
||||
my @report_id_row = map( $_->{header_key} eq 'Report_ID' ? $_ : (), @{ $header[0] } );
|
||||
my $report = $report_id_row[0];
|
||||
my @report_id_row =
|
||||
map( $_->{header_key} eq 'Report_ID' ? $_ : (), @{ $header[0] } );
|
||||
my $report = $report_id_row[0];
|
||||
|
||||
$self->type( $report->{header_value} );
|
||||
}
|
||||
|
|
@ -335,8 +335,7 @@ sub _get_rows_from_COUNTER_file {
|
|||
my ($self) = @_;
|
||||
|
||||
open my $fh, "<", \$self->file_content or die;
|
||||
my $csv = Text::CSV_XS->new(
|
||||
{ binary => 1, always_quote => 1, eol => $/, decode_utf8 => 1 } );
|
||||
my $csv = Text::CSV_XS->new( { binary => 1, always_quote => 1, eol => $/, decode_utf8 => 1 } );
|
||||
|
||||
my $header_columns = $csv->getline_all( $fh, 13, 1 );
|
||||
$csv->column_names( @{$header_columns}[0] );
|
||||
|
|
@ -360,14 +359,11 @@ sub _add_job_message {
|
|||
|
||||
if ( $self->type =~ /PR/i ) {
|
||||
$object_title = $row->{Platform};
|
||||
}
|
||||
elsif ( $self->type =~ /DR/i ) {
|
||||
} elsif ( $self->type =~ /DR/i ) {
|
||||
$object_title = $row->{Database};
|
||||
}
|
||||
elsif ( $self->type =~ /IR/i ) {
|
||||
} elsif ( $self->type =~ /IR/i ) {
|
||||
$object_title = $row->{Item};
|
||||
}
|
||||
elsif ( $self->type =~ /TR/i ) {
|
||||
} elsif ( $self->type =~ /TR/i ) {
|
||||
$object_title = $row->{Title};
|
||||
}
|
||||
|
||||
|
|
@ -391,14 +387,11 @@ sub _get_usage_object_id_hash {
|
|||
|
||||
if ( $self->type =~ /PR/i ) {
|
||||
return { platform_id => $usage_object->platform_id };
|
||||
}
|
||||
elsif ( $self->type =~ /DR/i ) {
|
||||
} elsif ( $self->type =~ /DR/i ) {
|
||||
return { database_id => $usage_object->database_id };
|
||||
}
|
||||
elsif ( $self->type =~ /IR/i ) {
|
||||
} elsif ( $self->type =~ /IR/i ) {
|
||||
return { item_id => $usage_object->item_id };
|
||||
}
|
||||
elsif ( $self->type =~ /TR/i ) {
|
||||
} elsif ( $self->type =~ /TR/i ) {
|
||||
return { title_id => $usage_object->title_id };
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -416,39 +409,32 @@ sub _search_for_usage_object {
|
|||
my $usage_data_provider = $self->get_usage_data_provider;
|
||||
|
||||
if ( $self->type =~ /PR/i ) {
|
||||
return Koha::ERM::UsagePlatforms->search(
|
||||
return Koha::ERM::EUsage::UsagePlatforms->search(
|
||||
{
|
||||
platform => $row->{Platform},
|
||||
usage_data_provider_id =>
|
||||
$usage_data_provider->erm_usage_data_provider_id
|
||||
usage_data_provider_id => $usage_data_provider->erm_usage_data_provider_id
|
||||
}
|
||||
)->last;
|
||||
}
|
||||
elsif ( $self->type =~ /DR/i ) {
|
||||
return Koha::ERM::UsageDatabases->search(
|
||||
} elsif ( $self->type =~ /DR/i ) {
|
||||
return Koha::ERM::EUsage::UsageDatabases->search(
|
||||
{
|
||||
database => $row->{Database},
|
||||
usage_data_provider_id =>
|
||||
$usage_data_provider->erm_usage_data_provider_id
|
||||
usage_data_provider_id => $usage_data_provider->erm_usage_data_provider_id
|
||||
}
|
||||
)->last;
|
||||
}
|
||||
elsif ( $self->type =~ /IR/i ) {
|
||||
return Koha::ERM::UsageItems->search(
|
||||
} elsif ( $self->type =~ /IR/i ) {
|
||||
return Koha::ERM::EUsage::UsageItems->search(
|
||||
{
|
||||
item => $row->{Item},
|
||||
publisher => $row->{Publisher},
|
||||
usage_data_provider_id =>
|
||||
$usage_data_provider->erm_usage_data_provider_id
|
||||
usage_data_provider_id => $usage_data_provider->erm_usage_data_provider_id
|
||||
}
|
||||
)->last;
|
||||
}
|
||||
elsif ( $self->type =~ /TR/i ) {
|
||||
return Koha::ERM::UsageTitles->search(
|
||||
} elsif ( $self->type =~ /TR/i ) {
|
||||
return Koha::ERM::EUsage::UsageTitles->search(
|
||||
{
|
||||
title_doi => $row->{DOI},
|
||||
usage_data_provider_id =>
|
||||
$usage_data_provider->erm_usage_data_provider_id
|
||||
usage_data_provider_id => $usage_data_provider->erm_usage_data_provider_id
|
||||
}
|
||||
)->last;
|
||||
}
|
||||
|
|
@ -467,19 +453,16 @@ sub _is_same_usage_object {
|
|||
|
||||
if ( $self->type =~ /PR/i ) {
|
||||
return $previous_object
|
||||
&& $previous_object->platform eq $row->{Platform};
|
||||
}
|
||||
elsif ( $self->type =~ /DR/i ) {
|
||||
&& $previous_object->platform eq $row->{Platform};
|
||||
} elsif ( $self->type =~ /DR/i ) {
|
||||
return $previous_object
|
||||
&& $previous_object->database eq $row->{Database};
|
||||
}
|
||||
elsif ( $self->type =~ /IR/i ) {
|
||||
&& $previous_object->database eq $row->{Database};
|
||||
} elsif ( $self->type =~ /IR/i ) {
|
||||
return
|
||||
$previous_object
|
||||
&& $previous_object->item eq $row->{Item}
|
||||
&& $previous_object->publisher eq $row->{Publisher};
|
||||
}
|
||||
elsif ( $self->type =~ /TR/i ) {
|
||||
$previous_object
|
||||
&& $previous_object->item eq $row->{Item}
|
||||
&& $previous_object->publisher eq $row->{Publisher};
|
||||
} elsif ( $self->type =~ /TR/i ) {
|
||||
return $previous_object && $previous_object->title_doi eq $row->{DOI};
|
||||
}
|
||||
|
||||
|
|
@ -522,15 +505,15 @@ Adds a erm_counter_logs database entry
|
|||
sub _add_counter_log_entry {
|
||||
my ($self) = @_;
|
||||
|
||||
Koha::ERM::CounterLog->new(
|
||||
Koha::ERM::EUsage::CounterLog->new(
|
||||
{
|
||||
#TODO: borrowernumber only required for manual uploads or "harvest now" button clicks
|
||||
#TODO: borrowernumber only required for manual uploads or "harvest now" button clicks
|
||||
borrowernumber => undef,
|
||||
counter_files_id => $self->erm_counter_files_id,
|
||||
importdate => $self->date_uploaded,
|
||||
filename => $self->filename,
|
||||
|
||||
#TODO: add eventual exceptions coming from the COUNTER report to logdetails?
|
||||
#TODO: add eventual exceptions coming from the COUNTER report to logdetails?
|
||||
logdetails => undef
|
||||
}
|
||||
)->store;
|
||||
|
|
@ -546,56 +529,50 @@ sub _add_usage_object_entry {
|
|||
my ( $self, $row ) = @_;
|
||||
|
||||
my $usage_data_provider = $self->get_usage_data_provider;
|
||||
my $specific_fields =
|
||||
$usage_data_provider->get_report_type_specific_fields( $self->type );
|
||||
my $specific_fields = $usage_data_provider->get_report_type_specific_fields( $self->type );
|
||||
|
||||
if ( $self->type =~ /PR/i ) {
|
||||
return Koha::ERM::UsagePlatform->new(
|
||||
return Koha::ERM::EUsage::UsagePlatform->new(
|
||||
{
|
||||
usage_data_provider_id =>
|
||||
$usage_data_provider->erm_usage_data_provider_id,
|
||||
platform => $row->{Platform},
|
||||
usage_data_provider_id => $usage_data_provider->erm_usage_data_provider_id,
|
||||
platform => $row->{Platform},
|
||||
}
|
||||
)->store;
|
||||
}
|
||||
elsif ( $self->type =~ /DR/i ) {
|
||||
return Koha::ERM::UsageDatabase->new(
|
||||
} elsif ( $self->type =~ /DR/i ) {
|
||||
return Koha::ERM::EUsage::UsageDatabase->new(
|
||||
{
|
||||
database => $row->{Database},
|
||||
usage_data_provider_id =>
|
||||
$usage_data_provider->erm_usage_data_provider_id,
|
||||
platform => $row->{Platform},
|
||||
publisher => $row->{Publisher},
|
||||
publisher_id => $row->{Publisher_ID},
|
||||
usage_data_provider_id => $usage_data_provider->erm_usage_data_provider_id,
|
||||
platform => $row->{Platform},
|
||||
publisher => $row->{Publisher},
|
||||
publisher_id => $row->{Publisher_ID},
|
||||
}
|
||||
)->store;
|
||||
}
|
||||
elsif ( $self->type =~ /IR/i ) {
|
||||
return Koha::ERM::UsageItem->new(
|
||||
} elsif ( $self->type =~ /IR/i ) {
|
||||
return Koha::ERM::EUsage::UsageItem->new(
|
||||
{
|
||||
item => $row->{Item},
|
||||
usage_data_provider_id =>
|
||||
$usage_data_provider->erm_usage_data_provider_id,
|
||||
platform => $row->{Platform},
|
||||
publisher => $row->{Publisher},
|
||||
usage_data_provider_id => $usage_data_provider->erm_usage_data_provider_id,
|
||||
platform => $row->{Platform},
|
||||
publisher => $row->{Publisher},
|
||||
}
|
||||
)->store;
|
||||
}
|
||||
elsif ( $self->type =~ /TR/i ) {
|
||||
return Koha::ERM::UsageTitle->new(
|
||||
} elsif ( $self->type =~ /TR/i ) {
|
||||
return Koha::ERM::EUsage::UsageTitle->new(
|
||||
{
|
||||
title => $row->{Title},
|
||||
usage_data_provider_id =>
|
||||
$usage_data_provider->erm_usage_data_provider_id,
|
||||
title_doi => $row->{DOI},
|
||||
print_issn => $row->{Print_ISSN},
|
||||
online_issn => $row->{Online_ISSN},
|
||||
title_uri => $row->{URI},
|
||||
publisher => $row->{Publisher},
|
||||
publisher_id => $row->{Publisher_ID},
|
||||
grep ( /YOP/, @{$specific_fields} ) ? ( yop => $row->{YOP} )
|
||||
usage_data_provider_id => $usage_data_provider->erm_usage_data_provider_id,
|
||||
title_doi => $row->{DOI},
|
||||
print_issn => $row->{Print_ISSN},
|
||||
online_issn => $row->{Online_ISSN},
|
||||
title_uri => $row->{URI},
|
||||
publisher => $row->{Publisher},
|
||||
publisher_id => $row->{Publisher_ID},
|
||||
grep ( /YOP/, @{$specific_fields} )
|
||||
? ( yop => $row->{YOP} )
|
||||
: (),
|
||||
grep ( /ISBN/, @{$specific_fields} ) ? ( isbn => $row->{ISBN} )
|
||||
grep ( /ISBN/, @{$specific_fields} )
|
||||
? ( isbn => $row->{ISBN} )
|
||||
: (),
|
||||
}
|
||||
)->store;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package Koha::ERM::CounterFiles;
|
||||
package Koha::ERM::EUsage::CounterFiles;
|
||||
|
||||
# Copyright 2023 PTFS Europe
|
||||
|
||||
|
|
@ -21,13 +21,13 @@ use Modern::Perl;
|
|||
|
||||
use Koha::Database;
|
||||
|
||||
use Koha::ERM::CounterFile;
|
||||
use Koha::ERM::EUsage::CounterFile;
|
||||
|
||||
use base qw(Koha::Objects);
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Koha::ERM::CounterFiles- Koha ErmCounterFile Object set class
|
||||
Koha::ERM::EUsage::CounterFiles- Koha ErmCounterFile Object set class
|
||||
|
||||
=head1 API
|
||||
|
||||
|
|
@ -48,7 +48,7 @@ sub _type {
|
|||
=cut
|
||||
|
||||
sub object_class {
|
||||
return 'Koha::ERM::CounterFile';
|
||||
return 'Koha::ERM::EUsage::CounterFile';
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package Koha::ERM::CounterLog;
|
||||
package Koha::ERM::EUsage::CounterLog;
|
||||
|
||||
# Copyright 2023 PTFS Europe
|
||||
|
||||
|
|
@ -23,7 +23,7 @@ use base qw(Koha::Object);
|
|||
|
||||
=head1 NAME
|
||||
|
||||
Koha::ERM::CounterLog - Koha ErmCounterLog Object class
|
||||
Koha::ERM::EUsage::CounterLog - Koha ErmCounterLog Object class
|
||||
|
||||
=head1 API
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package Koha::ERM::CounterLogs;
|
||||
package Koha::ERM::EUsage::CounterLogs;
|
||||
|
||||
# Copyright 2023 PTFS Europe
|
||||
|
||||
|
|
@ -21,13 +21,13 @@ use Modern::Perl;
|
|||
|
||||
use Koha::Database;
|
||||
|
||||
use Koha::ERM::CounterLog;
|
||||
use Koha::ERM::EUsage::CounterLog;
|
||||
|
||||
use base qw(Koha::Objects);
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Koha::ERM::CounterLogs- Koha ErmCounterLog Object set class
|
||||
Koha::ERM::EUsage::CounterLogs- Koha ErmCounterLog Object set class
|
||||
|
||||
=head1 API
|
||||
|
||||
|
|
@ -48,7 +48,7 @@ sub _type {
|
|||
=cut
|
||||
|
||||
sub object_class {
|
||||
return 'Koha::ERM::CounterLog';
|
||||
return 'Koha::ERM::EUsage::CounterLog';
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package Koha::ERM::DefaultUsageReport;
|
||||
package Koha::ERM::EUsage::DefaultUsageReport;
|
||||
|
||||
# Copyright 2023 PTFS Europe
|
||||
|
||||
|
|
@ -23,7 +23,7 @@ use base qw(Koha::Object);
|
|||
|
||||
=head1 NAME
|
||||
|
||||
Koha::ERM::DefaultUsageReport - Koha ErmDefaultUsageReport Object class
|
||||
Koha::ERM::EUsage::DefaultUsageReport - Koha ErmDefaultUsageReport Object class
|
||||
|
||||
=head1 API
|
||||
|
||||
|
|
@ -41,4 +41,4 @@ sub _type {
|
|||
return 'ErmDefaultUsageReport';
|
||||
}
|
||||
|
||||
1;
|
||||
1;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package Koha::ERM::DefaultUsageReports;
|
||||
package Koha::ERM::EUsage::DefaultUsageReports;
|
||||
|
||||
# Copyright 2023 PTFS Europe
|
||||
|
||||
|
|
@ -21,13 +21,13 @@ use Modern::Perl;
|
|||
|
||||
use Koha::Database;
|
||||
|
||||
use Koha::ERM::DefaultUsageReport;
|
||||
use Koha::ERM::EUsage::DefaultUsageReport;
|
||||
|
||||
use base qw(Koha::Objects);
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Koha::ERM::DefaultUsageReports- Koha ErmDefaultUsageReport Object set class
|
||||
Koha::ERM::EUsage::DefaultUsageReports- Koha ErmDefaultUsageReport Object set class
|
||||
|
||||
=head1 API
|
||||
|
||||
|
|
@ -48,7 +48,7 @@ sub _type {
|
|||
=cut
|
||||
|
||||
sub object_class {
|
||||
return 'Koha::ERM::DefaultUsageReport';
|
||||
return 'Koha::ERM::EUsage::DefaultUsageReport';
|
||||
}
|
||||
|
||||
1;
|
||||
1;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package Koha::ERM::MonthlyUsage;
|
||||
package Koha::ERM::EUsage::MonthlyUsage;
|
||||
|
||||
# Copyright 2023 PTFS Europe
|
||||
|
||||
|
|
@ -23,7 +23,7 @@ use base qw(Koha::Object);
|
|||
|
||||
=head1 NAME
|
||||
|
||||
Koha::ERM::MonthlyUsage - Koha ErmMonthlyUsage Object class
|
||||
Koha::ERM::EUsage::MonthlyUsage - Koha ErmMonthlyUsage Object class
|
||||
|
||||
=head1 API
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package Koha::ERM::MonthlyUsages;
|
||||
package Koha::ERM::EUsage::MonthlyUsages;
|
||||
|
||||
# Copyright 2023 PTFS Europe
|
||||
|
||||
|
|
@ -21,13 +21,13 @@ use Modern::Perl;
|
|||
|
||||
use Koha::Database;
|
||||
|
||||
use Koha::ERM::MonthlyUsage;
|
||||
use Koha::ERM::EUsage::MonthlyUsage;
|
||||
|
||||
use base qw(Koha::Objects);
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Koha::ERM::MonthlyUsages- Koha ErmMonthlyUsage Object set class
|
||||
Koha::ERM::EUsage::MonthlyUsages- Koha ErmMonthlyUsage Object set class
|
||||
|
||||
=head1 API
|
||||
|
||||
|
|
@ -48,7 +48,7 @@ sub _type {
|
|||
=cut
|
||||
|
||||
sub object_class {
|
||||
return 'Koha::ERM::MonthlyUsage';
|
||||
return 'Koha::ERM::EUsage::MonthlyUsage';
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package Koha::ERM::UsageDataProvider;
|
||||
package Koha::ERM::EUsage::UsageDataProvider;
|
||||
|
||||
# Copyright 2023 PTFS Europe
|
||||
|
||||
|
|
@ -28,18 +28,18 @@ use Koha::Exceptions;
|
|||
|
||||
use base qw(Koha::Object);
|
||||
|
||||
use Koha::ERM::CounterFile;
|
||||
use Koha::ERM::CounterFiles;
|
||||
use Koha::ERM::UsageTitles;
|
||||
use Koha::ERM::UsageItems;
|
||||
use Koha::ERM::UsagePlatforms;
|
||||
use Koha::ERM::UsageDatabases;
|
||||
use Koha::ERM::MonthlyUsages;
|
||||
use Koha::ERM::EUsage::CounterFile;
|
||||
use Koha::ERM::EUsage::CounterFiles;
|
||||
use Koha::ERM::EUsage::UsageTitles;
|
||||
use Koha::ERM::EUsage::UsageItems;
|
||||
use Koha::ERM::EUsage::UsagePlatforms;
|
||||
use Koha::ERM::EUsage::UsageDatabases;
|
||||
use Koha::ERM::EUsage::MonthlyUsages;
|
||||
use Koha::BackgroundJob::ErmSushiHarvester;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Koha::ERM::UsageDataProvider - Koha ErmUsageDataProvider Object class
|
||||
Koha::ERM::EUsage::UsageDataProvider - Koha ErmUsageDataProvider Object class
|
||||
|
||||
=head1 API
|
||||
|
||||
|
|
@ -56,12 +56,11 @@ sub counter_files {
|
|||
|
||||
if ($counter_files) {
|
||||
for my $counter_file (@$counter_files) {
|
||||
Koha::ERM::CounterFile->new($counter_file)
|
||||
->store( $self->{job_callbacks} );
|
||||
Koha::ERM::EUsage::CounterFile->new($counter_file)->store( $self->{job_callbacks} );
|
||||
}
|
||||
}
|
||||
my $counter_files_rs = $self->_result->erm_counter_files;
|
||||
return Koha::ERM::CounterFiles->_new_from_dbic($counter_files_rs);
|
||||
return Koha::ERM::EUsage::CounterFiles->_new_from_dbic($counter_files_rs);
|
||||
}
|
||||
|
||||
=head3 enqueue_counter_file_processing_job
|
||||
|
|
@ -83,9 +82,7 @@ sub enqueue_counter_file_processing_job {
|
|||
|
||||
push(
|
||||
@jobs,
|
||||
{
|
||||
job_id => $job_id
|
||||
}
|
||||
{ job_id => $job_id }
|
||||
);
|
||||
|
||||
return \@jobs;
|
||||
|
|
@ -189,8 +186,8 @@ sub harvest_sushi {
|
|||
for my $r (@$result) {
|
||||
$message .= $r->{message};
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
#TODO: May want to check $result->{Report_Header}->{Exceptions} here
|
||||
$message = $result->{message} || $result->{Message} || q{};
|
||||
if ( $result->{errors} ) {
|
||||
|
|
@ -202,21 +199,19 @@ sub harvest_sushi {
|
|||
|
||||
#TODO: May want to add a job error message here?
|
||||
warn sprintf "ERROR - SUSHI service %s returned %s - %s\n", $url,
|
||||
$response->code, $message;
|
||||
$response->code, $message;
|
||||
if ( $response->code == 404 ) {
|
||||
Koha::Exceptions::ObjectNotFound->throw($message);
|
||||
}
|
||||
elsif ( $response->code == 401 ) {
|
||||
} elsif ( $response->code == 401 ) {
|
||||
Koha::Exceptions::Authorization::Unauthorized->throw($message);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
#TODO: May want to add a job error message here?
|
||||
die sprintf "ERROR requesting SUSHI service\n%s\ncode %s: %s\n",
|
||||
$url, $response->code,
|
||||
$message;
|
||||
$url, $response->code,
|
||||
$message;
|
||||
}
|
||||
}
|
||||
elsif ( $response->code == 204 ) { # No content
|
||||
} elsif ( $response->code == 204 ) { # No content
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -279,8 +274,10 @@ sub parse_SUSHI_response {
|
|||
my @report_column_headings = $self->_COUNTER_report_column_headings;
|
||||
my @report_body = $self->_COUNTER_report_body;
|
||||
|
||||
$self->_build_COUNTER_report_file( \@report_header,
|
||||
\@report_column_headings, \@report_body );
|
||||
$self->_build_COUNTER_report_file(
|
||||
\@report_header,
|
||||
\@report_column_headings, \@report_body
|
||||
);
|
||||
}
|
||||
|
||||
=head2 Internal methods
|
||||
|
|
@ -296,8 +293,8 @@ sub _build_url_query {
|
|||
|
||||
unless ( $self->service_url && $self->customer_id ) {
|
||||
die sprintf
|
||||
"SUSHI Harvesting config for usage data provider %d is missing service_url or customer_id\n",
|
||||
$self->erm_usage_data_provider_id;
|
||||
"SUSHI Harvesting config for usage data provider %d is missing service_url or customer_id\n",
|
||||
$self->erm_usage_data_provider_id;
|
||||
}
|
||||
|
||||
# FIXME: service_url needs to end in 'reports/'
|
||||
|
|
@ -335,7 +332,7 @@ sub _build_COUNTER_report_file {
|
|||
{
|
||||
usage_data_provider_id => $self->erm_usage_data_provider_id,
|
||||
file_content => $counter_file,
|
||||
date_uploaded => POSIX::strftime( "%Y%m%d%H%M%S", localtime ),
|
||||
date_uploaded => POSIX::strftime( "%Y%m%d%H%M%S", localtime ),
|
||||
|
||||
#TODO: add ".csv" to end of filename here
|
||||
filename => $self->name . "_" . $self->{report_type},
|
||||
|
|
@ -356,13 +353,10 @@ sub _COUNTER_report_header {
|
|||
|
||||
my $header = $self->{sushi}->{header};
|
||||
|
||||
my @metric_types_string =
|
||||
$self->_get_SUSHI_Name_Value( $header->{Report_Filters}, "Metric_Type" );
|
||||
my @metric_types_string = $self->_get_SUSHI_Name_Value( $header->{Report_Filters}, "Metric_Type" );
|
||||
|
||||
my $begin_date =
|
||||
$self->_get_SUSHI_Name_Value( $header->{Report_Filters}, "Begin_Date" );
|
||||
my $end_date =
|
||||
$self->_get_SUSHI_Name_Value( $header->{Report_Filters}, "End_Date" );
|
||||
my $begin_date = $self->_get_SUSHI_Name_Value( $header->{Report_Filters}, "Begin_Date" );
|
||||
my $end_date = $self->_get_SUSHI_Name_Value( $header->{Report_Filters}, "End_Date" );
|
||||
|
||||
return (
|
||||
[ Report_Name => $header->{Report_Name} || "" ],
|
||||
|
|
@ -374,42 +368,32 @@ sub _COUNTER_report_header {
|
|||
"; ",
|
||||
map( $_->{Type} . ":" . $_->{Value},
|
||||
@{ $header->{Institution_ID} } )
|
||||
)
|
||||
|| ""
|
||||
],
|
||||
[
|
||||
Metric_Types => join( "; ", split( /\|/, $metric_types_string[0] ) )
|
||||
|| ""
|
||||
)
|
||||
|| ""
|
||||
],
|
||||
[ Metric_Types => join( "; ", split( /\|/, $metric_types_string[0] ) ) || "" ],
|
||||
[
|
||||
Report_Filters => join(
|
||||
"; ",
|
||||
map( $_->{Name} . ":" . $_->{Value},
|
||||
@{ $header->{Report_Filters} } )
|
||||
)
|
||||
|| ""
|
||||
)
|
||||
|| ""
|
||||
],
|
||||
|
||||
#TODO: Report_Attributes may need parsing, test this with a SUSHI response that provides it
|
||||
#TODO: Report_Attributes may need parsing, test this with a SUSHI response that provides it
|
||||
[ Report_Attributes => $header->{Report_Attributes} || "" ],
|
||||
[
|
||||
Exceptions => join(
|
||||
"; ",
|
||||
map( $_->{Code} . ": "
|
||||
. $_->{Message} . " ("
|
||||
. $_->{Data} . ")",
|
||||
map( $_->{Code} . ": " . $_->{Message} . " (" . $_->{Data} . ")",
|
||||
@{ $header->{Exceptions} } )
|
||||
)
|
||||
|| ""
|
||||
)
|
||||
|| ""
|
||||
],
|
||||
[
|
||||
Reporting_Period => "Begin_Date="
|
||||
. $begin_date
|
||||
. "; End_Date="
|
||||
. $end_date
|
||||
],
|
||||
[ Created => $header->{Created} || "" ],
|
||||
[ Created_By => $header->{Created_By} || "" ],
|
||||
[ Reporting_Period => "Begin_Date=" . $begin_date . "; End_Date=" . $end_date ],
|
||||
[ Created => $header->{Created} || "" ],
|
||||
[ Created_By => $header->{Created_By} || "" ],
|
||||
[""] #empty 13th line
|
||||
);
|
||||
}
|
||||
|
|
@ -427,17 +411,17 @@ sub _COUNTER_item_report_row {
|
|||
return (
|
||||
[
|
||||
$item_row->{Item}
|
||||
|| "",
|
||||
|| "",
|
||||
$item_row->{Publisher}
|
||||
|| "",
|
||||
|| "",
|
||||
$self->_get_SUSHI_Type_Value( $item_row->{Publisher_ID}, "ISNI" )
|
||||
|| "",
|
||||
|| "",
|
||||
$item_row->{Platform}
|
||||
|| "",
|
||||
|| "",
|
||||
$self->_get_SUSHI_Type_Value( $item_row->{Item_ID}, "DOI" )
|
||||
|| "",
|
||||
|| "",
|
||||
$item_row->{Proprietary_ID}
|
||||
|| "",
|
||||
|| "",
|
||||
"", #FIXME: What goes in URI?
|
||||
$metric_type,
|
||||
$total_usage,
|
||||
|
|
@ -454,16 +438,17 @@ https://cop5.projectcounter.org/en/5.0.2/04-reports/02-database-reports.html#col
|
|||
=cut
|
||||
|
||||
sub _COUNTER_database_report_row {
|
||||
my ( $self, $database_row, $metric_type, $total_usage, $monthly_usages ) =
|
||||
@_;
|
||||
my ( $self, $database_row, $metric_type, $total_usage, $monthly_usages ) = @_;
|
||||
|
||||
return (
|
||||
[
|
||||
$database_row->{Database} || "",
|
||||
$database_row->{Publisher} || "",
|
||||
$self->_get_SUSHI_Type_Value( $database_row->{Publisher_ID},
|
||||
"ISNI" )
|
||||
|| "",
|
||||
$self->_get_SUSHI_Type_Value(
|
||||
$database_row->{Publisher_ID},
|
||||
"ISNI"
|
||||
)
|
||||
|| "",
|
||||
$database_row->{Platform} || "",
|
||||
$database_row->{Proprietary_ID} || "",
|
||||
$metric_type,
|
||||
|
|
@ -481,8 +466,7 @@ https://cop5.projectcounter.org/en/5.0.2/04-reports/01-platform-reports.html#col
|
|||
=cut
|
||||
|
||||
sub _COUNTER_platform_report_row {
|
||||
my ( $self, $platform_row, $metric_type, $total_usage, $monthly_usages ) =
|
||||
@_;
|
||||
my ( $self, $platform_row, $metric_type, $total_usage, $monthly_usages ) = @_;
|
||||
|
||||
return (
|
||||
[
|
||||
|
|
@ -502,9 +486,8 @@ https://cop5.projectcounter.org/en/5.0.2/04-reports/03-title-reports.html#column
|
|||
sub _COUNTER_title_report_row {
|
||||
my ( $self, $title_row, $metric_type, $total_usage, $monthly_usages ) = @_;
|
||||
|
||||
my $header = $self->{sushi}->{header};
|
||||
my $specific_fields =
|
||||
$self->get_report_type_specific_fields( $header->{Report_ID} );
|
||||
my $header = $self->{sushi}->{header};
|
||||
my $specific_fields = $self->get_report_type_specific_fields( $header->{Report_ID} );
|
||||
|
||||
return (
|
||||
[
|
||||
|
|
@ -516,7 +499,7 @@ sub _COUNTER_title_report_row {
|
|||
|
||||
# Publisher_ID
|
||||
$self->_get_SUSHI_Type_Value( $title_row->{Publisher_ID}, "ISNI" )
|
||||
|| "",
|
||||
|| "",
|
||||
|
||||
# Platform
|
||||
$title_row->{Platform} || "",
|
||||
|
|
@ -525,26 +508,22 @@ sub _COUNTER_title_report_row {
|
|||
$self->_get_SUSHI_Type_Value( $title_row->{Item_ID}, "DOI" ) || "",
|
||||
|
||||
# Proprietary_ID
|
||||
$self->_get_SUSHI_Type_Value(
|
||||
$title_row->{Item_ID}, "Proprietary"
|
||||
)
|
||||
|| "",
|
||||
$self->_get_SUSHI_Type_Value( $title_row->{Item_ID}, "Proprietary" )
|
||||
|| "",
|
||||
|
||||
# ISBN
|
||||
grep ( /ISBN/, @{$specific_fields} )
|
||||
? ( $self->_get_SUSHI_Type_Value( $title_row->{Item_ID}, "ISBN" )
|
||||
|| "" )
|
||||
|| "" )
|
||||
: (),
|
||||
|
||||
# Print_ISSN
|
||||
$self->_get_SUSHI_Type_Value( $title_row->{Item_ID}, "Print_ISSN" )
|
||||
|| "",
|
||||
|| "",
|
||||
|
||||
# Online_ISSN
|
||||
$self->_get_SUSHI_Type_Value(
|
||||
$title_row->{Item_ID}, "Online_ISSN"
|
||||
)
|
||||
|| "",
|
||||
$self->_get_SUSHI_Type_Value( $title_row->{Item_ID}, "Online_ISSN" )
|
||||
|| "",
|
||||
|
||||
# URI - FIXME: What goes in URI?
|
||||
"",
|
||||
|
|
@ -582,24 +561,28 @@ sub _COUNTER_report_row {
|
|||
|
||||
my $header = $self->{sushi}->{header};
|
||||
|
||||
my ( $total_usage, @monthly_usages ) =
|
||||
$self->_get_row_usages( $report_row, $metric_type );
|
||||
my ( $total_usage, @monthly_usages ) = $self->_get_row_usages( $report_row, $metric_type );
|
||||
|
||||
if ( $header->{Report_ID} =~ /PR/i ) {
|
||||
return $self->_COUNTER_platform_report_row( $report_row, $metric_type,
|
||||
$total_usage, \@monthly_usages );
|
||||
}
|
||||
elsif ( $header->{Report_ID} =~ /DR/i ) {
|
||||
return $self->_COUNTER_database_report_row( $report_row, $metric_type,
|
||||
$total_usage, \@monthly_usages );
|
||||
}
|
||||
elsif ( $header->{Report_ID} =~ /IR/i ) {
|
||||
return $self->_COUNTER_item_report_row( $report_row, $metric_type,
|
||||
$total_usage, \@monthly_usages );
|
||||
}
|
||||
elsif ( $header->{Report_ID} =~ /TR/i ) {
|
||||
return $self->_COUNTER_title_report_row( $report_row, $metric_type,
|
||||
$total_usage, \@monthly_usages );
|
||||
return $self->_COUNTER_platform_report_row(
|
||||
$report_row, $metric_type,
|
||||
$total_usage, \@monthly_usages
|
||||
);
|
||||
} elsif ( $header->{Report_ID} =~ /DR/i ) {
|
||||
return $self->_COUNTER_database_report_row(
|
||||
$report_row, $metric_type,
|
||||
$total_usage, \@monthly_usages
|
||||
);
|
||||
} elsif ( $header->{Report_ID} =~ /IR/i ) {
|
||||
return $self->_COUNTER_item_report_row(
|
||||
$report_row, $metric_type,
|
||||
$total_usage, \@monthly_usages
|
||||
);
|
||||
} elsif ( $header->{Report_ID} =~ /TR/i ) {
|
||||
return $self->_COUNTER_title_report_row(
|
||||
$report_row, $metric_type,
|
||||
$total_usage, \@monthly_usages
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -626,11 +609,10 @@ sub _get_row_usages {
|
|||
|
||||
my $instances = $performance->{Instance};
|
||||
my @metric_type_count =
|
||||
map( $_->{Metric_Type} eq $metric_type ? $_->{Count} : (),
|
||||
map( $_->{Metric_Type} eq $metric_type ? $_->{Count} : (),
|
||||
@{$instances} );
|
||||
|
||||
if ( $period_usage_month eq $usage_month && $metric_type_count[0] )
|
||||
{
|
||||
if ( $period_usage_month eq $usage_month && $metric_type_count[0] ) {
|
||||
push( @usage_months_fields, $metric_type_count[0] );
|
||||
$count_total += $metric_type_count[0];
|
||||
$month_is_empty = 0;
|
||||
|
|
@ -666,18 +648,20 @@ sub _COUNTER_report_body {
|
|||
# Grab all metric_types this SUSHI result has statistics for
|
||||
foreach my $performance ( @{ $report_row->{Performance} } ) {
|
||||
my @SUSHI_metric_types =
|
||||
map( $_->{Metric_Type}, @{ $performance->{Instance} } );
|
||||
map( $_->{Metric_Type}, @{ $performance->{Instance} } );
|
||||
|
||||
foreach my $sushi_metric_type (@SUSHI_metric_types) {
|
||||
push( @metric_types, $sushi_metric_type )
|
||||
unless grep { $_ eq $sushi_metric_type } @metric_types;
|
||||
unless grep { $_ eq $sushi_metric_type } @metric_types;
|
||||
}
|
||||
}
|
||||
|
||||
# Add one report row for each metric_type we're working with
|
||||
foreach my $metric_type (@metric_types) {
|
||||
push( @report_body,
|
||||
$self->_COUNTER_report_row( $report_row, $metric_type ) );
|
||||
push(
|
||||
@report_body,
|
||||
$self->_COUNTER_report_row( $report_row, $metric_type )
|
||||
);
|
||||
}
|
||||
$self->{total_records} = ++$total_records;
|
||||
}
|
||||
|
|
@ -728,14 +712,11 @@ sub _COUNTER_report_column_headings {
|
|||
|
||||
if ( $header->{Report_ID} =~ /PR/i ) {
|
||||
return $self->_COUNTER_platforms_report_column_headings;
|
||||
}
|
||||
elsif ( $header->{Report_ID} =~ /DR/i ) {
|
||||
} elsif ( $header->{Report_ID} =~ /DR/i ) {
|
||||
return $self->_COUNTER_databases_report_column_headings;
|
||||
}
|
||||
elsif ( $header->{Report_ID} =~ /IR/i ) {
|
||||
} elsif ( $header->{Report_ID} =~ /IR/i ) {
|
||||
return $self->_COUNTER_items_report_column_headings;
|
||||
}
|
||||
elsif ( $header->{Report_ID} =~ /TR/i ) {
|
||||
} elsif ( $header->{Report_ID} =~ /TR/i ) {
|
||||
return $self->_COUNTER_titles_report_column_headings;
|
||||
}
|
||||
|
||||
|
|
@ -800,7 +781,7 @@ sub _COUNTER_items_report_column_headings {
|
|||
"Metric_Type",
|
||||
"Reporting_Period_Total",
|
||||
|
||||
# @month_headings in "Mmm-yyyy" format. TODO: Show unless Exclude_Monthly_Details=true
|
||||
# @month_headings in "Mmm-yyyy" format. TODO: Show unless Exclude_Monthly_Details=true
|
||||
@month_headings
|
||||
]
|
||||
);
|
||||
|
|
@ -828,7 +809,7 @@ sub _COUNTER_databases_report_column_headings {
|
|||
"Metric_Type",
|
||||
"Reporting_Period_Total",
|
||||
|
||||
# @month_headings in "Mmm-yyyy" format. TODO: Show unless Exclude_Monthly_Details=true
|
||||
# @month_headings in "Mmm-yyyy" format. TODO: Show unless Exclude_Monthly_Details=true
|
||||
@month_headings
|
||||
]
|
||||
);
|
||||
|
|
@ -852,7 +833,7 @@ sub _COUNTER_platforms_report_column_headings {
|
|||
"Metric_Type",
|
||||
"Reporting_Period_Total",
|
||||
|
||||
# @month_headings in "Mmm-yyyy" format. TODO: Show unless Exclude_Monthly_Details=true
|
||||
# @month_headings in "Mmm-yyyy" format. TODO: Show unless Exclude_Monthly_Details=true
|
||||
@month_headings
|
||||
]
|
||||
);
|
||||
|
|
@ -867,10 +848,9 @@ Return titles report column headings
|
|||
sub _COUNTER_titles_report_column_headings {
|
||||
my ($self) = @_;
|
||||
|
||||
my $header = $self->{sushi}->{header};
|
||||
my @month_headings = $self->_get_usage_months( $header, 1 );
|
||||
my $specific_fields =
|
||||
$self->get_report_type_specific_fields( $header->{Report_ID} );
|
||||
my $header = $self->{sushi}->{header};
|
||||
my @month_headings = $self->_get_usage_months( $header, 1 );
|
||||
my $specific_fields = $self->get_report_type_specific_fields( $header->{Report_ID} );
|
||||
|
||||
return (
|
||||
[
|
||||
|
|
@ -894,7 +874,7 @@ sub _COUNTER_titles_report_column_headings {
|
|||
"Metric_Type",
|
||||
"Reporting_Period_Total",
|
||||
|
||||
# @month_headings in "Mmm-yyyy" format. TODO: Show unless Exclude_Monthly_Details=true
|
||||
# @month_headings in "Mmm-yyyy" format. TODO: Show unless Exclude_Monthly_Details=true
|
||||
@month_headings
|
||||
]
|
||||
);
|
||||
|
|
@ -926,10 +906,12 @@ sub _get_usage_months {
|
|||
|
||||
my @month_headings = ();
|
||||
while ( $begin_month <= $end_month || $begin_year < $end_year ) {
|
||||
push( @month_headings,
|
||||
$column_headings_formatting
|
||||
push(
|
||||
@month_headings,
|
||||
$column_headings_formatting
|
||||
? $months[ $begin_month - 1 ] . " " . $begin_year
|
||||
: $begin_year . "-" . $begin_month );
|
||||
: $begin_year . "-" . $begin_month
|
||||
);
|
||||
$begin_month++;
|
||||
if ( $begin_month > 12 ) {
|
||||
$begin_month = 1;
|
||||
|
|
@ -985,14 +967,12 @@ sub test_connection {
|
|||
my $message = $response->{_msg};
|
||||
if ( $response->{_rc} == 404 ) {
|
||||
Koha::Exceptions::ObjectNotFound->throw($message);
|
||||
}
|
||||
elsif ( $response->{_rc} == 401 ) {
|
||||
} elsif ( $response->{_rc} == 401 ) {
|
||||
Koha::Exceptions::Authorization::Unauthorized->throw($message);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
die sprintf "ERROR testing SUSHI service\n%s\ncode %s: %s\n",
|
||||
$url, $response->{_rc},
|
||||
$message;
|
||||
$url, $response->{_rc},
|
||||
$message;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1002,15 +982,13 @@ sub test_connection {
|
|||
for my $r (@$result) {
|
||||
$status = $r->{Service_Active};
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$status = $result->{Service_Active};
|
||||
}
|
||||
|
||||
if ($status) {
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -1024,7 +1002,7 @@ Method to embed erm_usage_titles to titles for report formatting
|
|||
sub erm_usage_titles {
|
||||
my ($self) = @_;
|
||||
my $usage_title_rs = $self->_result->erm_usage_titles;
|
||||
return Koha::ERM::UsageTitles->_new_from_dbic($usage_title_rs);
|
||||
return Koha::ERM::EUsage::UsageTitles->_new_from_dbic($usage_title_rs);
|
||||
}
|
||||
|
||||
=head3 erm_usage_muses
|
||||
|
|
@ -1036,11 +1014,9 @@ Method to embed erm_usage_muses to titles for report formatting
|
|||
sub erm_usage_muses {
|
||||
my ($self) = @_;
|
||||
my $usage_mus_rs = $self->_result->erm_usage_muses;
|
||||
return Koha::ERM::MonthlyUsages->_new_from_dbic($usage_mus_rs);
|
||||
return Koha::ERM::EUsage::MonthlyUsages->_new_from_dbic($usage_mus_rs);
|
||||
}
|
||||
|
||||
|
||||
|
||||
=head3 erm_usage_platforms
|
||||
|
||||
Method to embed erm_usage_platforms to platforms for report formatting
|
||||
|
|
@ -1050,7 +1026,7 @@ Method to embed erm_usage_platforms to platforms for report formatting
|
|||
sub erm_usage_platforms {
|
||||
my ( $self ) = @_;
|
||||
my $usage_platform_rs = $self->_result->erm_usage_platforms;
|
||||
return Koha::ERM::UsagePlatforms->_new_from_dbic($usage_platform_rs);
|
||||
return Koha::ERM::EUsage::UsagePlatforms->_new_from_dbic($usage_platform_rs);
|
||||
}
|
||||
|
||||
=head3 erm_usage_items
|
||||
|
|
@ -1062,7 +1038,7 @@ Method to embed erm_usage_items to items for report formatting
|
|||
sub erm_usage_items {
|
||||
my ( $self ) = @_;
|
||||
my $usage_item_rs = $self->_result->erm_usage_items;
|
||||
return Koha::ERM::UsageItems->_new_from_dbic($usage_item_rs);
|
||||
return Koha::ERM::EUsage::UsageItems->_new_from_dbic($usage_item_rs);
|
||||
}
|
||||
|
||||
=head3 erm_usage_databases
|
||||
|
|
@ -1074,7 +1050,7 @@ Method to embed erm_usage_databases to databases for report formatting
|
|||
sub erm_usage_databases {
|
||||
my ( $self ) = @_;
|
||||
my $usage_database_rs = $self->_result->erm_usage_databases;
|
||||
return Koha::ERM::UsageDatabases->_new_from_dbic($usage_database_rs);
|
||||
return Koha::ERM::EUsage::UsageDatabases->_new_from_dbic($usage_database_rs);
|
||||
}
|
||||
|
||||
=head3 _type
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package Koha::ERM::UsageDataProviders;
|
||||
package Koha::ERM::EUsage::UsageDataProviders;
|
||||
|
||||
# Copyright 2023 PTFS Europe
|
||||
|
||||
|
|
@ -21,13 +21,13 @@ use Modern::Perl;
|
|||
|
||||
use Koha::Database;
|
||||
|
||||
use Koha::ERM::UsageDataProvider;
|
||||
use Koha::ERM::EUsage::UsageDataProvider;
|
||||
|
||||
use base qw(Koha::Objects);
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Koha::ERM::UsageDataProviders- Koha ErmUsageDataProvider Object set class
|
||||
Koha::ERM::EUsage::UsageDataProviders- Koha ErmUsageDataProvider Object set class
|
||||
|
||||
=head1 API
|
||||
|
||||
|
|
@ -48,7 +48,7 @@ sub _type {
|
|||
=cut
|
||||
|
||||
sub object_class {
|
||||
return 'Koha::ERM::UsageDataProvider';
|
||||
return 'Koha::ERM::EUsage::UsageDataProvider';
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package Koha::ERM::UsageDatabase;
|
||||
package Koha::ERM::EUsage::UsageDatabase;
|
||||
|
||||
# Copyright 2023 PTFS Europe
|
||||
|
||||
|
|
@ -21,14 +21,14 @@ use Modern::Perl;
|
|||
|
||||
use base qw(Koha::Object);
|
||||
|
||||
use Koha::ERM::YearlyUsage;
|
||||
use Koha::ERM::YearlyUsages;
|
||||
use Koha::ERM::MonthlyUsage;
|
||||
use Koha::ERM::MonthlyUsages;
|
||||
use Koha::ERM::EUsage::YearlyUsage;
|
||||
use Koha::ERM::EUsage::YearlyUsages;
|
||||
use Koha::ERM::EUsage::MonthlyUsage;
|
||||
use Koha::ERM::EUsage::MonthlyUsages;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Koha::ERM::UsageDatabase - Koha ErmUsageDatabaseObject class
|
||||
Koha::ERM::EUsage::UsageDatabase - Koha ErmUsageDatabaseObject class
|
||||
|
||||
=head1 API
|
||||
|
||||
|
|
@ -42,7 +42,7 @@ Method to embed erm_usage_muses to databases for report formatting
|
|||
sub erm_usage_muses {
|
||||
my ($self) = @_;
|
||||
my $usage_mus_rs = $self->_result->erm_usage_muses;
|
||||
return Koha::ERM::MonthlyUsages->_new_from_dbic($usage_mus_rs);
|
||||
return Koha::ERM::EUsage::MonthlyUsages->_new_from_dbic($usage_mus_rs);
|
||||
}
|
||||
|
||||
=head3 erm_usage_yuses
|
||||
|
|
@ -54,7 +54,7 @@ Method to embed erm_usage_yuses to databases for report formatting
|
|||
sub erm_usage_yuses {
|
||||
my ($self) = @_;
|
||||
my $usage_yus_rs = $self->_result->erm_usage_yuses;
|
||||
return Koha::ERM::YearlyUsages->_new_from_dbic($usage_yus_rs);
|
||||
return Koha::ERM::EUsage::YearlyUsages->_new_from_dbic($usage_yus_rs);
|
||||
}
|
||||
|
||||
=head3 yearly_usages
|
||||
|
|
@ -71,16 +71,16 @@ sub yearly_usages {
|
|||
for my $yearly_usage (@$yearly_usages) {
|
||||
if ( $self->yearly_usages()->search($yearly_usage)->last ) {
|
||||
$job_callbacks->{report_info_callback}->('skipped_yus')
|
||||
if $job_callbacks;
|
||||
if $job_callbacks;
|
||||
next;
|
||||
}
|
||||
$job_callbacks->{report_info_callback}->('added_yus')
|
||||
if $job_callbacks;
|
||||
Koha::ERM::YearlyUsage->new($yearly_usage)->store;
|
||||
if $job_callbacks;
|
||||
Koha::ERM::EUsage::YearlyUsage->new($yearly_usage)->store;
|
||||
}
|
||||
}
|
||||
my $yearly_usages_rs = $self->_result->erm_usage_yuses;
|
||||
return Koha::ERM::YearlyUsages->_new_from_dbic($yearly_usages_rs);
|
||||
return Koha::ERM::EUsage::YearlyUsages->_new_from_dbic($yearly_usages_rs);
|
||||
}
|
||||
|
||||
=head3 monthly_usages
|
||||
|
|
@ -97,16 +97,16 @@ sub monthly_usages {
|
|||
for my $monthly_usage (@$monthly_usages) {
|
||||
if ( $self->monthly_usages()->search($monthly_usage)->last ) {
|
||||
$job_callbacks->{report_info_callback}->('skipped_mus')
|
||||
if $job_callbacks;
|
||||
if $job_callbacks;
|
||||
next;
|
||||
}
|
||||
$job_callbacks->{report_info_callback}->('added_mus')
|
||||
if $job_callbacks;
|
||||
Koha::ERM::MonthlyUsage->new($monthly_usage)->store;
|
||||
if $job_callbacks;
|
||||
Koha::ERM::EUsage::MonthlyUsage->new($monthly_usage)->store;
|
||||
}
|
||||
}
|
||||
my $monthly_usages_rs = $self->_result->erm_usage_muses;
|
||||
return Koha::ERM::MonthlyUsages->_new_from_dbic($monthly_usages_rs);
|
||||
return Koha::ERM::EUsage::MonthlyUsages->_new_from_dbic($monthly_usages_rs);
|
||||
}
|
||||
|
||||
=head2 Internal methods
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package Koha::ERM::UsageDatabases;
|
||||
package Koha::ERM::EUsage::UsageDatabases;
|
||||
|
||||
# Copyright 2023 PTFS Europe
|
||||
|
||||
|
|
@ -21,13 +21,13 @@ use Modern::Perl;
|
|||
|
||||
use Koha::Database;
|
||||
|
||||
use Koha::ERM::UsageDatabase;
|
||||
use Koha::ERM::EUsage::UsageDatabase;
|
||||
|
||||
use base qw(Koha::Objects);
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Koha::ERM::UsageDatabases- Koha ErmUsageDatabase Object set class
|
||||
Koha::ERM::EUsage::UsageDatabases- Koha ErmUsageDatabase Object set class
|
||||
|
||||
=head1 API
|
||||
|
||||
|
|
@ -48,7 +48,7 @@ sub _type {
|
|||
=cut
|
||||
|
||||
sub object_class {
|
||||
return 'Koha::ERM::UsageDatabase';
|
||||
return 'Koha::ERM::EUsage::UsageDatabase';
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package Koha::ERM::UsageItem;
|
||||
package Koha::ERM::EUsage::UsageItem;
|
||||
|
||||
# Copyright 2023 PTFS Europe
|
||||
|
||||
|
|
@ -21,14 +21,14 @@ use Modern::Perl;
|
|||
|
||||
use base qw(Koha::Object);
|
||||
|
||||
use Koha::ERM::YearlyUsage;
|
||||
use Koha::ERM::YearlyUsages;
|
||||
use Koha::ERM::MonthlyUsage;
|
||||
use Koha::ERM::MonthlyUsages;
|
||||
use Koha::ERM::EUsage::YearlyUsage;
|
||||
use Koha::ERM::EUsage::YearlyUsages;
|
||||
use Koha::ERM::EUsage::MonthlyUsage;
|
||||
use Koha::ERM::EUsage::MonthlyUsages;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Koha::ERM::UsageItem - Koha ErmUsageItemObject class
|
||||
Koha::ERM::EUsage::UsageItem - Koha ErmUsageItemObject class
|
||||
|
||||
=head1 API
|
||||
|
||||
|
|
@ -42,7 +42,7 @@ Method to embed erm_usage_muses to items for report formatting
|
|||
sub erm_usage_muses {
|
||||
my ($self) = @_;
|
||||
my $usage_mus_rs = $self->_result->erm_usage_muses;
|
||||
return Koha::ERM::MonthlyUsages->_new_from_dbic($usage_mus_rs);
|
||||
return Koha::ERM::EUsage::MonthlyUsages->_new_from_dbic($usage_mus_rs);
|
||||
}
|
||||
|
||||
=head3 erm_usage_yuses
|
||||
|
|
@ -54,7 +54,7 @@ Method to embed erm_usage_yuses to items for report formatting
|
|||
sub erm_usage_yuses {
|
||||
my ($self) = @_;
|
||||
my $usage_yus_rs = $self->_result->erm_usage_yuses;
|
||||
return Koha::ERM::YearlyUsages->_new_from_dbic($usage_yus_rs);
|
||||
return Koha::ERM::EUsage::YearlyUsages->_new_from_dbic($usage_yus_rs);
|
||||
}
|
||||
|
||||
=head3 yearly_usages
|
||||
|
|
@ -71,16 +71,16 @@ sub yearly_usages {
|
|||
for my $yearly_usage (@$yearly_usages) {
|
||||
if ( $self->yearly_usages()->search($yearly_usage)->last ) {
|
||||
$job_callbacks->{report_info_callback}->('skipped_yus')
|
||||
if $job_callbacks;
|
||||
if $job_callbacks;
|
||||
next;
|
||||
}
|
||||
$job_callbacks->{report_info_callback}->('added_yus')
|
||||
if $job_callbacks;
|
||||
Koha::ERM::YearlyUsage->new($yearly_usage)->store;
|
||||
if $job_callbacks;
|
||||
Koha::ERM::EUsage::YearlyUsage->new($yearly_usage)->store;
|
||||
}
|
||||
}
|
||||
my $yearly_usages_rs = $self->_result->erm_usage_yuses;
|
||||
return Koha::ERM::YearlyUsages->_new_from_dbic($yearly_usages_rs);
|
||||
return Koha::ERM::EUsage::YearlyUsages->_new_from_dbic($yearly_usages_rs);
|
||||
}
|
||||
|
||||
=head3 monthly_usages
|
||||
|
|
@ -97,16 +97,16 @@ sub monthly_usages {
|
|||
for my $monthly_usage (@$monthly_usages) {
|
||||
if ( $self->monthly_usages()->search($monthly_usage)->last ) {
|
||||
$job_callbacks->{report_info_callback}->('skipped_mus')
|
||||
if $job_callbacks;
|
||||
if $job_callbacks;
|
||||
next;
|
||||
}
|
||||
$job_callbacks->{report_info_callback}->('added_mus')
|
||||
if $job_callbacks;
|
||||
Koha::ERM::MonthlyUsage->new($monthly_usage)->store;
|
||||
if $job_callbacks;
|
||||
Koha::ERM::EUsage::MonthlyUsage->new($monthly_usage)->store;
|
||||
}
|
||||
}
|
||||
my $monthly_usages_rs = $self->_result->erm_usage_muses;
|
||||
return Koha::ERM::MonthlyUsages->_new_from_dbic($monthly_usages_rs);
|
||||
return Koha::ERM::EUsage::MonthlyUsages->_new_from_dbic($monthly_usages_rs);
|
||||
}
|
||||
|
||||
=head2 Internal methods
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package Koha::ERM::UsageItems;
|
||||
package Koha::ERM::EUsage::UsageItems;
|
||||
|
||||
# Copyright 2023 PTFS Europe
|
||||
|
||||
|
|
@ -21,13 +21,13 @@ use Modern::Perl;
|
|||
|
||||
use Koha::Database;
|
||||
|
||||
use Koha::ERM::UsageItem;
|
||||
use Koha::ERM::EUsage::UsageItem;
|
||||
|
||||
use base qw(Koha::Objects);
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Koha::ERM::UsageItems- Koha ErmUsageItem Object set class
|
||||
Koha::ERM::EUsage::UsageItems- Koha ErmUsageItem Object set class
|
||||
|
||||
=head1 API
|
||||
|
||||
|
|
@ -48,7 +48,7 @@ sub _type {
|
|||
=cut
|
||||
|
||||
sub object_class {
|
||||
return 'Koha::ERM::UsageItem';
|
||||
return 'Koha::ERM::EUsage::UsageItem';
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package Koha::ERM::UsagePlatform;
|
||||
package Koha::ERM::EUsage::UsagePlatform;
|
||||
|
||||
# Copyright 2023 PTFS Europe
|
||||
|
||||
|
|
@ -21,14 +21,14 @@ use Modern::Perl;
|
|||
|
||||
use base qw(Koha::Object);
|
||||
|
||||
use Koha::ERM::YearlyUsage;
|
||||
use Koha::ERM::YearlyUsages;
|
||||
use Koha::ERM::MonthlyUsage;
|
||||
use Koha::ERM::MonthlyUsages;
|
||||
use Koha::ERM::EUsage::YearlyUsage;
|
||||
use Koha::ERM::EUsage::YearlyUsages;
|
||||
use Koha::ERM::EUsage::MonthlyUsage;
|
||||
use Koha::ERM::EUsage::MonthlyUsages;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Koha::ERM::UsagePlatform - Koha ErmUsagePlatform Object class
|
||||
Koha::ERM::EUsage::UsagePlatform - Koha ErmUsagePlatform Object class
|
||||
|
||||
=head1 API
|
||||
|
||||
|
|
@ -42,7 +42,7 @@ Method to embed erm_usage_muses to platforms for report formatting
|
|||
sub erm_usage_muses {
|
||||
my ($self) = @_;
|
||||
my $usage_mus_rs = $self->_result->erm_usage_muses;
|
||||
return Koha::ERM::MonthlyUsages->_new_from_dbic($usage_mus_rs);
|
||||
return Koha::ERM::EUsage::MonthlyUsages->_new_from_dbic($usage_mus_rs);
|
||||
}
|
||||
|
||||
=head3 erm_usage_yuses
|
||||
|
|
@ -54,7 +54,7 @@ Method to embed erm_usage_yuses to platforms for report formatting
|
|||
sub erm_usage_yuses {
|
||||
my ($self) = @_;
|
||||
my $usage_yus_rs = $self->_result->erm_usage_yuses;
|
||||
return Koha::ERM::YearlyUsages->_new_from_dbic($usage_yus_rs);
|
||||
return Koha::ERM::EUsage::YearlyUsages->_new_from_dbic($usage_yus_rs);
|
||||
}
|
||||
|
||||
=head3 yearly_usages
|
||||
|
|
@ -71,16 +71,16 @@ sub yearly_usages {
|
|||
for my $yearly_usage (@$yearly_usages) {
|
||||
if ( $self->yearly_usages()->search($yearly_usage)->last ) {
|
||||
$job_callbacks->{report_info_callback}->('skipped_yus')
|
||||
if $job_callbacks;
|
||||
if $job_callbacks;
|
||||
next;
|
||||
}
|
||||
$job_callbacks->{report_info_callback}->('added_yus')
|
||||
if $job_callbacks;
|
||||
Koha::ERM::YearlyUsage->new($yearly_usage)->store;
|
||||
if $job_callbacks;
|
||||
Koha::ERM::EUsage::YearlyUsage->new($yearly_usage)->store;
|
||||
}
|
||||
}
|
||||
my $yearly_usages_rs = $self->_result->erm_usage_yuses;
|
||||
return Koha::ERM::YearlyUsages->_new_from_dbic($yearly_usages_rs);
|
||||
return Koha::ERM::EUsage::YearlyUsages->_new_from_dbic($yearly_usages_rs);
|
||||
}
|
||||
|
||||
=head3 monthly_usages
|
||||
|
|
@ -97,16 +97,16 @@ sub monthly_usages {
|
|||
for my $monthly_usage (@$monthly_usages) {
|
||||
if ( $self->monthly_usages()->search($monthly_usage)->last ) {
|
||||
$job_callbacks->{report_info_callback}->('skipped_mus')
|
||||
if $job_callbacks;
|
||||
if $job_callbacks;
|
||||
next;
|
||||
}
|
||||
$job_callbacks->{report_info_callback}->('added_mus')
|
||||
if $job_callbacks;
|
||||
Koha::ERM::MonthlyUsage->new($monthly_usage)->store;
|
||||
if $job_callbacks;
|
||||
Koha::ERM::EUsage::MonthlyUsage->new($monthly_usage)->store;
|
||||
}
|
||||
}
|
||||
my $monthly_usages_rs = $self->_result->erm_usage_muses;
|
||||
return Koha::ERM::MonthlyUsages->_new_from_dbic($monthly_usages_rs);
|
||||
return Koha::ERM::EUsage::MonthlyUsages->_new_from_dbic($monthly_usages_rs);
|
||||
}
|
||||
|
||||
=head2 Internal methods
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package Koha::ERM::UsagePlatforms;
|
||||
package Koha::ERM::EUsage::UsagePlatforms;
|
||||
|
||||
# Copyright 2023 PTFS Europe
|
||||
|
||||
|
|
@ -21,13 +21,13 @@ use Modern::Perl;
|
|||
|
||||
use Koha::Database;
|
||||
|
||||
use Koha::ERM::UsagePlatform;
|
||||
use Koha::ERM::EUsage::UsagePlatform;
|
||||
|
||||
use base qw(Koha::Objects);
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Koha::ERM::UsagePlatforms- Koha ErmUsagePlatform Object set class
|
||||
Koha::ERM::EUsage::UsagePlatforms- Koha ErmUsagePlatform Object set class
|
||||
|
||||
=head1 API
|
||||
|
||||
|
|
@ -48,7 +48,7 @@ sub _type {
|
|||
=cut
|
||||
|
||||
sub object_class {
|
||||
return 'Koha::ERM::UsagePlatform';
|
||||
return 'Koha::ERM::EUsage::UsagePlatform';
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package Koha::ERM::UsageTitle;
|
||||
package Koha::ERM::EUsage::UsageTitle;
|
||||
|
||||
# Copyright 2023 PTFS Europe
|
||||
|
||||
|
|
@ -21,14 +21,14 @@ use Modern::Perl;
|
|||
|
||||
use base qw(Koha::Object);
|
||||
|
||||
use Koha::ERM::YearlyUsage;
|
||||
use Koha::ERM::YearlyUsages;
|
||||
use Koha::ERM::MonthlyUsage;
|
||||
use Koha::ERM::MonthlyUsages;
|
||||
use Koha::ERM::EUsage::YearlyUsage;
|
||||
use Koha::ERM::EUsage::YearlyUsages;
|
||||
use Koha::ERM::EUsage::MonthlyUsage;
|
||||
use Koha::ERM::EUsage::MonthlyUsages;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Koha::ERM::UsageTitle - Koha ErmUsageTitle Object class
|
||||
Koha::ERM::EUsage::UsageTitle - Koha ErmUsageTitle Object class
|
||||
|
||||
=head1 API
|
||||
|
||||
|
|
@ -42,7 +42,7 @@ Method to embed erm_usage_muses to titles for report formatting
|
|||
sub erm_usage_muses {
|
||||
my ($self) = @_;
|
||||
my $usage_mus_rs = $self->_result->erm_usage_muses;
|
||||
return Koha::ERM::MonthlyUsages->_new_from_dbic($usage_mus_rs);
|
||||
return Koha::ERM::EUsage::MonthlyUsages->_new_from_dbic($usage_mus_rs);
|
||||
}
|
||||
|
||||
=head3 erm_usage_yuses
|
||||
|
|
@ -54,7 +54,7 @@ Method to embed erm_usage_yuses to titles for report formatting
|
|||
sub erm_usage_yuses {
|
||||
my ($self) = @_;
|
||||
my $usage_yus_rs = $self->_result->erm_usage_yuses;
|
||||
return Koha::ERM::YearlyUsages->_new_from_dbic($usage_yus_rs);
|
||||
return Koha::ERM::EUsage::YearlyUsages->_new_from_dbic($usage_yus_rs);
|
||||
}
|
||||
|
||||
=head3 yearly_usages
|
||||
|
|
@ -71,16 +71,16 @@ sub yearly_usages {
|
|||
for my $yearly_usage (@$yearly_usages) {
|
||||
if ( $self->yearly_usages()->search($yearly_usage)->last ) {
|
||||
$job_callbacks->{report_info_callback}->('skipped_yus')
|
||||
if $job_callbacks;
|
||||
if $job_callbacks;
|
||||
next;
|
||||
}
|
||||
$job_callbacks->{report_info_callback}->('added_yus')
|
||||
if $job_callbacks;
|
||||
Koha::ERM::YearlyUsage->new($yearly_usage)->store;
|
||||
if $job_callbacks;
|
||||
Koha::ERM::EUsage::YearlyUsage->new($yearly_usage)->store;
|
||||
}
|
||||
}
|
||||
my $yearly_usages_rs = $self->_result->erm_usage_yuses;
|
||||
return Koha::ERM::YearlyUsages->_new_from_dbic($yearly_usages_rs);
|
||||
return Koha::ERM::EUsage::YearlyUsages->_new_from_dbic($yearly_usages_rs);
|
||||
}
|
||||
|
||||
=head3 monthly_usages
|
||||
|
|
@ -97,16 +97,16 @@ sub monthly_usages {
|
|||
for my $monthly_usage (@$monthly_usages) {
|
||||
if ( $self->monthly_usages()->search($monthly_usage)->last ) {
|
||||
$job_callbacks->{report_info_callback}->('skipped_mus')
|
||||
if $job_callbacks;
|
||||
if $job_callbacks;
|
||||
next;
|
||||
}
|
||||
$job_callbacks->{report_info_callback}->('added_mus')
|
||||
if $job_callbacks;
|
||||
Koha::ERM::MonthlyUsage->new($monthly_usage)->store;
|
||||
if $job_callbacks;
|
||||
Koha::ERM::EUsage::MonthlyUsage->new($monthly_usage)->store;
|
||||
}
|
||||
}
|
||||
my $monthly_usages_rs = $self->_result->erm_usage_muses;
|
||||
return Koha::ERM::MonthlyUsages->_new_from_dbic($monthly_usages_rs);
|
||||
return Koha::ERM::EUsage::MonthlyUsages->_new_from_dbic($monthly_usages_rs);
|
||||
}
|
||||
|
||||
=head2 Internal methods
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package Koha::ERM::UsageTitles;
|
||||
package Koha::ERM::EUsage::UsageTitles;
|
||||
|
||||
# Copyright 2023 PTFS Europe
|
||||
|
||||
|
|
@ -21,13 +21,13 @@ use Modern::Perl;
|
|||
|
||||
use Koha::Database;
|
||||
|
||||
use Koha::ERM::UsageTitle;
|
||||
use Koha::ERM::EUsage::UsageTitle;
|
||||
|
||||
use base qw(Koha::Objects);
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Koha::ERM::UsageTitles- Koha ErmUsageTitle Object set class
|
||||
Koha::ERM::EUsage::UsageTitles- Koha ErmUsageTitle Object set class
|
||||
|
||||
=head1 API
|
||||
|
||||
|
|
@ -48,7 +48,7 @@ sub _type {
|
|||
=cut
|
||||
|
||||
sub object_class {
|
||||
return 'Koha::ERM::UsageTitle';
|
||||
return 'Koha::ERM::EUsage::UsageTitle';
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package Koha::ERM::YearlyUsage;
|
||||
package Koha::ERM::EUsage::YearlyUsage;
|
||||
|
||||
# Copyright 2023 PTFS Europe
|
||||
|
||||
|
|
@ -23,7 +23,7 @@ use base qw(Koha::Object);
|
|||
|
||||
=head1 NAME
|
||||
|
||||
Koha::ERM::YearlyUsage - Koha ErmYearlyUsage Object class
|
||||
Koha::ERM::EUsage::YearlyUsage - Koha ErmYearlyUsage Object class
|
||||
|
||||
=head1 API
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package Koha::ERM::YearlyUsages;
|
||||
package Koha::ERM::EUsage::YearlyUsages;
|
||||
|
||||
# Copyright 2023 PTFS Europe
|
||||
|
||||
|
|
@ -21,13 +21,13 @@ use Modern::Perl;
|
|||
|
||||
use Koha::Database;
|
||||
|
||||
use Koha::ERM::YearlyUsage;
|
||||
use Koha::ERM::EUsage::YearlyUsage;
|
||||
|
||||
use base qw(Koha::Objects);
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Koha::ERM::YearlyUsages- Koha ErmYearlyUsage Object set class
|
||||
Koha::ERM::EUsage::YearlyUsages- Koha ErmYearlyUsage Object set class
|
||||
|
||||
=head1 API
|
||||
|
||||
|
|
@ -48,7 +48,7 @@ sub _type {
|
|||
=cut
|
||||
|
||||
sub object_class {
|
||||
return 'Koha::ERM::YearlyUsage';
|
||||
return 'Koha::ERM::EUsage::YearlyUsage';
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package Koha::Exceptions::ERM::CounterFile;
|
||||
package Koha::Exceptions::ERM::EUsage::CounterFile;
|
||||
|
||||
# This file is part of Koha.
|
||||
#
|
||||
|
|
@ -21,27 +21,27 @@ use Koha::Exception;
|
|||
|
||||
use Exception::Class (
|
||||
|
||||
'Koha::Exceptions::ERM::CounterFile' => {
|
||||
'Koha::Exceptions::ERM::EUsage::CounterFile' => {
|
||||
isa => 'Koha::Exception',
|
||||
},
|
||||
'Koha::Exceptions::ERM::CounterFile::UnsupportedRelease' => {
|
||||
isa => 'Koha::Exceptions::ERM::CounterFile',
|
||||
'Koha::Exceptions::ERM::EUsage::CounterFile::UnsupportedRelease' => {
|
||||
isa => 'Koha::Exceptions::ERM::EUsage::CounterFile',
|
||||
description => 'This COUNTER release is not supported'
|
||||
}
|
||||
);
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Koha::Exceptions::ERM::CounterFile - Base class for CounterFile exceptions
|
||||
Koha::Exceptions::ERM::EUsage::CounterFile - Base class for CounterFile exceptions
|
||||
|
||||
=head1 Exceptions
|
||||
|
||||
|
||||
=head2 Koha::Exceptions::ERM::CounterFile
|
||||
=head2 Koha::Exceptions::ERM::EUsage::CounterFile
|
||||
|
||||
Generic CounterFile exception
|
||||
|
||||
=head2 Koha::Exceptions::ERM::CounterFile::UnsupportedRelease
|
||||
=head2 Koha::Exceptions::ERM::EUsage::CounterFile::UnsupportedRelease
|
||||
|
||||
Exception to be used when a report is submit with an unsupported COUNTER release
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package Koha::REST::V1::ERM::CounterFiles;
|
||||
package Koha::REST::V1::ERM::EUsage::CounterFiles;
|
||||
|
||||
# Copyright 2023 PTFS Europe
|
||||
|
||||
|
|
@ -21,7 +21,7 @@ use Modern::Perl;
|
|||
|
||||
use Mojo::Base 'Mojolicious::Controller';
|
||||
|
||||
use Koha::ERM::CounterFiles;
|
||||
use Koha::ERM::EUsage::CounterFiles;
|
||||
|
||||
use Scalar::Util qw( blessed );
|
||||
use Try::Tiny qw( catch try );
|
||||
|
|
@ -38,11 +38,10 @@ sub list {
|
|||
my $c = shift->openapi->valid_input or return;
|
||||
|
||||
return try {
|
||||
my $counter_files_set = Koha::ERM::CounterFiles->new;
|
||||
my $counter_files_set = Koha::ERM::EUsage::CounterFiles->new;
|
||||
my $counter_files = $c->objects->search($counter_files_set);
|
||||
return $c->render( status => 200, openapi => $counter_files );
|
||||
}
|
||||
catch {
|
||||
} catch {
|
||||
$c->unhandled_exception($_);
|
||||
};
|
||||
|
||||
|
|
@ -50,7 +49,7 @@ sub list {
|
|||
|
||||
=head3 get
|
||||
|
||||
Controller function that handles retrieving a single Koha::ERM::CounterFile object
|
||||
Controller function that handles retrieving a single Koha::ERM::EUsage::CounterFile object
|
||||
|
||||
=cut
|
||||
|
||||
|
|
@ -61,7 +60,7 @@ sub get {
|
|||
my $counter_file_id = $c->validation->param('erm_counter_files_id');
|
||||
|
||||
# Do not use $c->objects->find here, we need the file_content
|
||||
my $counter_file = Koha::ERM::CounterFiles->find($counter_file_id);
|
||||
my $counter_file = Koha::ERM::EUsage::CounterFiles->find($counter_file_id);
|
||||
|
||||
if ( !$counter_file ) {
|
||||
return $c->render(
|
||||
|
|
@ -74,8 +73,7 @@ sub get {
|
|||
'data' => $counter_file->file_content,
|
||||
'filename' => $counter_file->filename . '.csv'
|
||||
);
|
||||
}
|
||||
catch {
|
||||
} catch {
|
||||
$c->unhandled_exception($_);
|
||||
};
|
||||
}
|
||||
|
|
@ -88,7 +86,7 @@ sub delete {
|
|||
my $c = shift->openapi->valid_input or return;
|
||||
|
||||
my $counter_file_id = $c->validation->param('erm_counter_files_id');
|
||||
my $counter_file = Koha::ERM::CounterFiles->find($counter_file_id);
|
||||
my $counter_file = Koha::ERM::EUsage::CounterFiles->find($counter_file_id);
|
||||
unless ($counter_file) {
|
||||
return $c->render(
|
||||
status => 404,
|
||||
|
|
@ -102,8 +100,7 @@ sub delete {
|
|||
status => 204,
|
||||
openapi => q{}
|
||||
);
|
||||
}
|
||||
catch {
|
||||
} catch {
|
||||
$c->unhandled_exception($_);
|
||||
};
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package Koha::REST::V1::ERM::CounterRegistry;
|
||||
package Koha::REST::V1::ERM::EUsage::CounterRegistry;
|
||||
|
||||
# Copyright 2023 PTFS Europe
|
||||
|
||||
|
|
@ -43,7 +43,7 @@ sub list {
|
|||
my $json = JSON->new;
|
||||
|
||||
my @query_params_array =
|
||||
map { $_ ? $json->decode($_) : () } @{ $args->{q} };
|
||||
map { $_ ? $json->decode($_) : () } @{ $args->{q} };
|
||||
my $search_string = $query_params_array[0]->{name};
|
||||
|
||||
my $url = 'https://registry.projectcounter.org/api/v1/platform/';
|
||||
|
|
@ -61,8 +61,7 @@ sub list {
|
|||
for my $r (@$result) {
|
||||
$message .= $r->{message};
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$message = $result->{message} || $result->{Message} || q{};
|
||||
if ( $result->{errors} ) {
|
||||
for my $e ( @{ $result->{errors} } ) {
|
||||
|
|
@ -71,21 +70,17 @@ sub list {
|
|||
}
|
||||
}
|
||||
warn sprintf "ERROR - Counter registry API %s returned %s - %s\n", $url,
|
||||
$response->code, $message;
|
||||
$response->code, $message;
|
||||
if ( $response->code == 404 ) {
|
||||
Koha::Exceptions::ObjectNotFound->throw($message);
|
||||
}
|
||||
elsif ( $response->code == 401 ) {
|
||||
} elsif ( $response->code == 401 ) {
|
||||
Koha::Exceptions::Authorization::Unauthorized->throw($message);
|
||||
} else {
|
||||
die sprintf "ERROR requesting Counter registry API\n%s\ncode %s: %s\n", $url,
|
||||
$response->code,
|
||||
$message;
|
||||
}
|
||||
else {
|
||||
die sprintf
|
||||
"ERROR requesting Counter registry API\n%s\ncode %s: %s\n", $url,
|
||||
$response->code,
|
||||
$message;
|
||||
}
|
||||
}
|
||||
elsif ( $response->code == 204 ) { # No content
|
||||
} elsif ( $response->code == 204 ) { # No content
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -94,8 +89,7 @@ sub list {
|
|||
my @counter_5_supporting_platforms;
|
||||
foreach my $platform (@$result) {
|
||||
my $name_check = index( lc $platform->{name}, lc $search_string );
|
||||
my @services = grep { $_->{counter_release} eq '5' }
|
||||
@{ $platform->{sushi_services} };
|
||||
my @services = grep { $_->{counter_release} eq '5' } @{ $platform->{sushi_services} };
|
||||
if ( scalar(@services) > 0
|
||||
&& $name_check != -1
|
||||
&& scalar( @{ $platform->{reports} } ) > 0 )
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package Koha::REST::V1::ERM::CustomReports;
|
||||
package Koha::REST::V1::ERM::EUsage::CustomReports;
|
||||
|
||||
# Copyright 2023 PTFS Europe
|
||||
|
||||
|
|
@ -21,12 +21,12 @@ use Modern::Perl;
|
|||
|
||||
use Mojo::Base 'Mojolicious::Controller';
|
||||
|
||||
use Koha::ERM::UsageTitles;
|
||||
use Koha::ERM::UsagePlatforms;
|
||||
use Koha::ERM::UsageItems;
|
||||
use Koha::ERM::UsageDatabases;
|
||||
use Koha::ERM::UsageDataProvider;
|
||||
use Koha::ERM::UsageDataProviders;
|
||||
use Koha::ERM::EUsage::UsageTitles;
|
||||
use Koha::ERM::EUsage::UsagePlatforms;
|
||||
use Koha::ERM::EUsage::UsageItems;
|
||||
use Koha::ERM::EUsage::UsageDatabases;
|
||||
use Koha::ERM::EUsage::UsageDataProvider;
|
||||
use Koha::ERM::EUsage::UsageDataProviders;
|
||||
|
||||
use Clone qw( clone );
|
||||
use Scalar::Util qw( blessed );
|
||||
|
|
@ -56,7 +56,7 @@ sub monthly_report {
|
|||
if ( ref( $args->{q} ) eq 'ARRAY' ) {
|
||||
foreach my $q ( @{ $args->{q} } ) {
|
||||
push @query_params_array, $json->decode($q)
|
||||
if $q;
|
||||
if $q;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -65,14 +65,15 @@ sub monthly_report {
|
|||
my $data = $c->objects->search($data_set);
|
||||
|
||||
my $usage_data_providers =
|
||||
Koha::ERM::UsageDataProviders->search( {}, {} )->unblessed;
|
||||
Koha::ERM::EUsage::UsageDataProviders->search( {}, {} )->unblessed;
|
||||
my $metric_types =
|
||||
$query_params_array[0][0]->{'erm_usage_muses.metric_type'};
|
||||
$query_params_array[0][0]->{'erm_usage_muses.metric_type'};
|
||||
|
||||
# Objects with no data in the selected range will not be returned by the API - we still want to include them if they have been requested
|
||||
my $requested_ids =
|
||||
_get_correct_query_param( $data_type, \@query_params_array,
|
||||
'monthly' );
|
||||
# Objects with no data in the selected range will not be returned by the API - we still want to include them if they have been requested
|
||||
my $requested_ids = _get_correct_query_param(
|
||||
$data_type, \@query_params_array,
|
||||
'monthly'
|
||||
);
|
||||
for my $id ( @{$requested_ids} ) {
|
||||
my $missing_result = _get_result_with_no_statistics(
|
||||
{
|
||||
|
|
@ -90,21 +91,21 @@ sub monthly_report {
|
|||
|
||||
# Add provider name rather than embed provider object
|
||||
my $usage_data_provider_id = $data_object->{usage_data_provider_id};
|
||||
my @provider_object = grep {
|
||||
$usage_data_provider_id eq $_->{erm_usage_data_provider_id}
|
||||
} @{$usage_data_providers};
|
||||
my @provider_object =
|
||||
grep { $usage_data_provider_id eq $_->{erm_usage_data_provider_id} } @{$usage_data_providers};
|
||||
my $provider_name = $provider_object[0]->{name};
|
||||
|
||||
# Split data objects into metric_types i.e. one table row per metric_type
|
||||
# Split data objects into metric_types i.e. one table row per metric_type
|
||||
for my $metric_type (@$metric_types) {
|
||||
my $statistics = $data_object->{'erm_usage_muses'};
|
||||
my @filtered_statistics =
|
||||
grep { $metric_type eq $_->{metric_type} } @$statistics;
|
||||
grep { $metric_type eq $_->{metric_type} } @$statistics;
|
||||
my @usage_counts =
|
||||
map { $_->{usage_count} } @filtered_statistics;
|
||||
my $sum = scalar(@usage_counts) > 0
|
||||
? eval join '+', @usage_counts
|
||||
: 0;
|
||||
map { $_->{usage_count} } @filtered_statistics;
|
||||
my $sum =
|
||||
scalar(@usage_counts) > 0
|
||||
? eval join '+', @usage_counts
|
||||
: 0;
|
||||
|
||||
my $data_object_hash = _get_object_hash(
|
||||
{
|
||||
|
|
@ -123,8 +124,7 @@ sub monthly_report {
|
|||
}
|
||||
|
||||
return $c->render( status => 200, openapi => \@report_data );
|
||||
}
|
||||
catch {
|
||||
} catch {
|
||||
$c->unhandled_exception($_);
|
||||
};
|
||||
|
||||
|
|
@ -148,7 +148,7 @@ sub yearly_report {
|
|||
if ( ref( $args->{q} ) eq 'ARRAY' ) {
|
||||
foreach my $q ( @{ $args->{q} } ) {
|
||||
push @query_params_array, $json->decode($q)
|
||||
if $q;
|
||||
if $q;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -157,12 +157,13 @@ sub yearly_report {
|
|||
my $data = $c->objects->search($data_set);
|
||||
|
||||
my $usage_data_providers =
|
||||
Koha::ERM::UsageDataProviders->search( {}, {} )->unblessed;
|
||||
Koha::ERM::EUsage::UsageDataProviders->search( {}, {} )->unblessed;
|
||||
|
||||
# Titles with no data in the selected range will not be returned by the API - we still want to include them if they have been requested
|
||||
my $requested_ids =
|
||||
_get_correct_query_param( $data_type, \@query_params_array,
|
||||
'yearly' );
|
||||
# Titles with no data in the selected range will not be returned by the API - we still want to include them if they have been requested
|
||||
my $requested_ids = _get_correct_query_param(
|
||||
$data_type, \@query_params_array,
|
||||
'yearly'
|
||||
);
|
||||
for my $id ( @{$requested_ids} ) {
|
||||
my $missing_result = _get_result_with_no_statistics(
|
||||
{
|
||||
|
|
@ -174,24 +175,22 @@ sub yearly_report {
|
|||
push @{$data}, $missing_result if $missing_result;
|
||||
}
|
||||
|
||||
my $metric_types =
|
||||
$query_params_array[0]->{'erm_usage_yuses.metric_type'};
|
||||
my $metric_types = $query_params_array[0]->{'erm_usage_yuses.metric_type'};
|
||||
my @report_data;
|
||||
|
||||
for my $data_object ( @{$data} ) {
|
||||
|
||||
# Add provider name rather than embed provider object
|
||||
my $usage_data_provider_id = $data_object->{usage_data_provider_id};
|
||||
my @provider_object = grep {
|
||||
$usage_data_provider_id eq $_->{erm_usage_data_provider_id}
|
||||
} @{$usage_data_providers};
|
||||
my @provider_object =
|
||||
grep { $usage_data_provider_id eq $_->{erm_usage_data_provider_id} } @{$usage_data_providers};
|
||||
my $provider_name = $provider_object[0]->{name};
|
||||
|
||||
# Split data objects into metric_types i.e. one table row per metric_type
|
||||
# Split data objects into metric_types i.e. one table row per metric_type
|
||||
for my $metric_type (@$metric_types) {
|
||||
my $statistics = $data_object->{'erm_usage_yuses'};
|
||||
my @filtered_statistics =
|
||||
grep { $metric_type eq $_->{metric_type} } @$statistics;
|
||||
grep { $metric_type eq $_->{metric_type} } @$statistics;
|
||||
|
||||
my $data_object_hash = _get_object_hash(
|
||||
{
|
||||
|
|
@ -209,8 +208,7 @@ sub yearly_report {
|
|||
}
|
||||
|
||||
return $c->render( status => 200, openapi => \@report_data );
|
||||
}
|
||||
catch {
|
||||
} catch {
|
||||
$c->unhandled_exception($_);
|
||||
};
|
||||
|
||||
|
|
@ -235,7 +233,7 @@ sub metric_types_report {
|
|||
if ( ref( $args->{q} ) eq 'ARRAY' ) {
|
||||
foreach my $q ( @{ $args->{q} } ) {
|
||||
push @query_params_array, $json->decode($q)
|
||||
if $q;
|
||||
if $q;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -244,12 +242,13 @@ sub metric_types_report {
|
|||
my $data = $c->objects->search($data_set);
|
||||
|
||||
my $usage_data_providers =
|
||||
Koha::ERM::UsageDataProviders->search( {}, {} )->unblessed;
|
||||
Koha::ERM::EUsage::UsageDataProviders->search( {}, {} )->unblessed;
|
||||
|
||||
# Objects with no data in the selected range will not be returned by the API - we still want to include them if they have been requested
|
||||
my $requested_ids =
|
||||
_get_correct_query_param( $data_type, \@query_params_array,
|
||||
'monthly' );
|
||||
# Objects with no data in the selected range will not be returned by the API - we still want to include them if they have been requested
|
||||
my $requested_ids = _get_correct_query_param(
|
||||
$data_type, \@query_params_array,
|
||||
'monthly'
|
||||
);
|
||||
for my $id ( @{$requested_ids} ) {
|
||||
my $missing_result = _get_result_with_no_statistics(
|
||||
{
|
||||
|
|
@ -267,17 +266,15 @@ sub metric_types_report {
|
|||
|
||||
# Add provider name rather than embed provider object
|
||||
my $usage_data_provider_id = $data_object->{usage_data_provider_id};
|
||||
my @provider_object = grep {
|
||||
$usage_data_provider_id eq $_->{erm_usage_data_provider_id}
|
||||
} @{$usage_data_providers};
|
||||
my @provider_object =
|
||||
grep { $usage_data_provider_id eq $_->{erm_usage_data_provider_id} } @{$usage_data_providers};
|
||||
my $provider_name = $provider_object[0]->{name};
|
||||
$data_object->{provider_name} = $provider_name;
|
||||
|
||||
push @report_data, $data_object;
|
||||
}
|
||||
return $c->render( status => 200, openapi => \@report_data );
|
||||
}
|
||||
catch {
|
||||
} catch {
|
||||
$c->unhandled_exception($_);
|
||||
};
|
||||
|
||||
|
|
@ -296,9 +293,8 @@ sub provider_rollup_report {
|
|||
|
||||
my $args = $c->validation->output;
|
||||
|
||||
my $usage_data_providers_set = Koha::ERM::UsageDataProviders->new;
|
||||
my $usage_data_providers =
|
||||
$c->objects->search($usage_data_providers_set);
|
||||
my $usage_data_providers_set = Koha::ERM::EUsage::UsageDataProviders->new;
|
||||
my $usage_data_providers = $c->objects->search($usage_data_providers_set);
|
||||
|
||||
my @query_params_array;
|
||||
my $json = JSON->new;
|
||||
|
|
@ -306,32 +302,33 @@ sub provider_rollup_report {
|
|||
if ( ref( $args->{q} ) eq 'ARRAY' ) {
|
||||
foreach my $q ( @{ $args->{q} } ) {
|
||||
push @query_params_array, $json->decode($q)
|
||||
if $q;
|
||||
if $q;
|
||||
}
|
||||
}
|
||||
|
||||
my $data_type = $c->validation->param('data_type');
|
||||
my $key = 'erm_usage_' . $data_type . 's';
|
||||
my $metric_types =
|
||||
$query_params_array[0][0]->{ $key . '.erm_usage_muses.metric_type' };
|
||||
$query_params_array[0][0]->{ $key . '.erm_usage_muses.metric_type' };
|
||||
|
||||
my @usage_data_provider_report_data;
|
||||
|
||||
for my $usage_data_provider ( @{$usage_data_providers} ) {
|
||||
|
||||
# Split usage_data_providers into metric_types i.e. one table row per metric_type
|
||||
# Split usage_data_providers into metric_types i.e. one table row per metric_type
|
||||
for my $metric_type (@$metric_types) {
|
||||
my @filtered_object_data;
|
||||
|
||||
for my $data_object ( @{ $usage_data_provider->{$key} } ) {
|
||||
my $statistics = $data_object->{'erm_usage_muses'};
|
||||
my @filtered_statistics =
|
||||
grep { $metric_type eq $_->{metric_type} } @$statistics;
|
||||
grep { $metric_type eq $_->{metric_type} } @$statistics;
|
||||
my @usage_counts =
|
||||
map { $_->{usage_count} } @filtered_statistics;
|
||||
my $sum = scalar(@usage_counts) > 0
|
||||
? eval join '+', @usage_counts
|
||||
: 0;
|
||||
map { $_->{usage_count} } @filtered_statistics;
|
||||
my $sum =
|
||||
scalar(@usage_counts) > 0
|
||||
? eval join '+', @usage_counts
|
||||
: 0;
|
||||
|
||||
my $data_object_hash = _get_object_hash(
|
||||
{
|
||||
|
|
@ -349,37 +346,36 @@ sub provider_rollup_report {
|
|||
}
|
||||
|
||||
my @data_object_usage_totals =
|
||||
map { $_->{usage_total} } @filtered_object_data;
|
||||
map { $_->{usage_total} } @filtered_object_data;
|
||||
my $provider_rollup_total =
|
||||
scalar(@data_object_usage_totals) > 0
|
||||
? eval join '+', @data_object_usage_totals
|
||||
: 0;
|
||||
scalar(@data_object_usage_totals) > 0
|
||||
? eval join '+', @data_object_usage_totals
|
||||
: 0;
|
||||
|
||||
my %usage_data_provider_hash = (
|
||||
erm_usage_data_provider_id =>
|
||||
$usage_data_provider->{erm_usage_data_provider_id},
|
||||
aggregator => $usage_data_provider->{aggregator},
|
||||
api_key => $usage_data_provider->{api_key},
|
||||
begin_date => $usage_data_provider->{begin_date},
|
||||
customer_id => $usage_data_provider->{customer_id},
|
||||
description => $usage_data_provider->{description},
|
||||
end_date => $usage_data_provider->{end_date},
|
||||
method => $usage_data_provider->{method},
|
||||
name => $usage_data_provider->{name},
|
||||
report_release => $usage_data_provider->{report_release},
|
||||
report_types => $usage_data_provider->{report_types},
|
||||
requestor_email => $usage_data_provider->{requestor_email},
|
||||
requestor_id => $usage_data_provider->{requestor_id},
|
||||
requestor_name => $usage_data_provider->{requestor_name},
|
||||
service_type => $usage_data_provider->{service_type},
|
||||
service_url => $usage_data_provider->{service_url},
|
||||
metric_type => $metric_type,
|
||||
provider_rollup_total => $provider_rollup_total,
|
||||
erm_usage_data_provider_id => $usage_data_provider->{erm_usage_data_provider_id},
|
||||
aggregator => $usage_data_provider->{aggregator},
|
||||
api_key => $usage_data_provider->{api_key},
|
||||
begin_date => $usage_data_provider->{begin_date},
|
||||
customer_id => $usage_data_provider->{customer_id},
|
||||
description => $usage_data_provider->{description},
|
||||
end_date => $usage_data_provider->{end_date},
|
||||
method => $usage_data_provider->{method},
|
||||
name => $usage_data_provider->{name},
|
||||
report_release => $usage_data_provider->{report_release},
|
||||
report_types => $usage_data_provider->{report_types},
|
||||
requestor_email => $usage_data_provider->{requestor_email},
|
||||
requestor_id => $usage_data_provider->{requestor_id},
|
||||
requestor_name => $usage_data_provider->{requestor_name},
|
||||
service_type => $usage_data_provider->{service_type},
|
||||
service_url => $usage_data_provider->{service_url},
|
||||
metric_type => $metric_type,
|
||||
provider_rollup_total => $provider_rollup_total,
|
||||
);
|
||||
$usage_data_provider_hash{$key} = \@filtered_object_data;
|
||||
|
||||
push @usage_data_provider_report_data,
|
||||
\%usage_data_provider_hash;
|
||||
\%usage_data_provider_hash;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -387,8 +383,7 @@ sub provider_rollup_report {
|
|||
status => 200,
|
||||
openapi => \@usage_data_provider_report_data
|
||||
);
|
||||
}
|
||||
catch {
|
||||
} catch {
|
||||
$c->unhandled_exception($_);
|
||||
};
|
||||
}
|
||||
|
|
@ -403,16 +398,16 @@ sub _get_data_set {
|
|||
my ($data_type) = @_;
|
||||
|
||||
if ( $data_type eq 'title' ) {
|
||||
return Koha::ERM::UsageTitles->new;
|
||||
return Koha::ERM::EUsage::UsageTitles->new;
|
||||
}
|
||||
if ( $data_type eq 'platform' ) {
|
||||
return Koha::ERM::UsagePlatforms->new;
|
||||
return Koha::ERM::EUsage::UsagePlatforms->new;
|
||||
}
|
||||
if ( $data_type eq 'item' ) {
|
||||
return Koha::ERM::UsageItems->new;
|
||||
return Koha::ERM::EUsage::UsageItems->new;
|
||||
}
|
||||
if ( $data_type eq 'database' ) {
|
||||
return Koha::ERM::UsageDatabases->new;
|
||||
return Koha::ERM::EUsage::UsageDatabases->new;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -435,8 +430,7 @@ sub _get_correct_query_param {
|
|||
|
||||
if ( $period eq 'monthly' ) {
|
||||
$param = $query_params[0][0]->{$key};
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$param = $query_params[0]->{$key};
|
||||
}
|
||||
|
||||
|
|
@ -543,8 +537,7 @@ sub _get_object_hash {
|
|||
|
||||
if ( $period eq 'yearly' ) {
|
||||
$object_hash{erm_usage_yuses} = $statistics;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$object_hash{erm_usage_muses} = $statistics;
|
||||
}
|
||||
return \%object_hash;
|
||||
|
|
@ -563,19 +556,17 @@ sub _get_missing_data {
|
|||
|
||||
if ( $data_type eq 'title' ) {
|
||||
$item =
|
||||
Koha::ERM::UsageTitles->find( { title_id => $id }, {} )->unblessed;
|
||||
Koha::ERM::EUsage::UsageTitles->find( { title_id => $id }, {} )->unblessed;
|
||||
}
|
||||
if ( $data_type eq 'platform' ) {
|
||||
$item = Koha::ERM::UsagePlatforms->find( { platform_id => $id }, {} )
|
||||
->unblessed;
|
||||
$item = Koha::ERM::EUsage::UsagePlatforms->find( { platform_id => $id }, {} )->unblessed;
|
||||
}
|
||||
if ( $data_type eq 'database' ) {
|
||||
$item = Koha::ERM::UsageDatabases->find( { database_id => $id }, {} )
|
||||
->unblessed;
|
||||
$item = Koha::ERM::EUsage::UsageDatabases->find( { database_id => $id }, {} )->unblessed;
|
||||
}
|
||||
if ( $data_type eq 'item' ) {
|
||||
$item =
|
||||
Koha::ERM::UsageItems->find( { item_id => $id }, {} )->unblessed;
|
||||
Koha::ERM::EUsage::UsageItems->find( { item_id => $id }, {} )->unblessed;
|
||||
}
|
||||
|
||||
return $item if $item;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package Koha::REST::V1::ERM::DefaultUsageReports;
|
||||
package Koha::REST::V1::ERM::EUsage::DefaultUsageReports;
|
||||
|
||||
# Copyright 2023 PTFS Europe
|
||||
|
||||
|
|
@ -21,8 +21,8 @@ use Modern::Perl;
|
|||
|
||||
use Mojo::Base 'Mojolicious::Controller';
|
||||
|
||||
use Koha::ERM::DefaultUsageReport;
|
||||
use Koha::ERM::DefaultUsageReports;
|
||||
use Koha::ERM::EUsage::DefaultUsageReport;
|
||||
use Koha::ERM::EUsage::DefaultUsageReports;
|
||||
|
||||
use Scalar::Util qw( blessed );
|
||||
use Try::Tiny qw( catch try );
|
||||
|
|
@ -39,12 +39,10 @@ sub list {
|
|||
my $c = shift->openapi->valid_input or return;
|
||||
|
||||
return try {
|
||||
my $default_usage_report_set = Koha::ERM::DefaultUsageReports->new;
|
||||
my $default_usage_report =
|
||||
$c->objects->search($default_usage_report_set);
|
||||
my $default_usage_report_set = Koha::ERM::EUsage::DefaultUsageReports->new;
|
||||
my $default_usage_report = $c->objects->search($default_usage_report_set);
|
||||
return $c->render( status => 200, openapi => $default_usage_report );
|
||||
}
|
||||
catch {
|
||||
} catch {
|
||||
$c->unhandled_exception($_);
|
||||
};
|
||||
|
||||
|
|
@ -52,7 +50,7 @@ sub list {
|
|||
|
||||
=head3 add
|
||||
|
||||
Controller function that handles adding a new Koha::ERM::DefaultUsageReport object
|
||||
Controller function that handles adding a new Koha::ERM::EUsage::DefaultUsageReport object
|
||||
|
||||
=cut
|
||||
|
||||
|
|
@ -65,51 +63,37 @@ sub add {
|
|||
|
||||
my $body = $c->validation->param('body');
|
||||
|
||||
my $default_report =
|
||||
Koha::ERM::DefaultUsageReport->new_from_api($body)->store;
|
||||
my $default_report = Koha::ERM::EUsage::DefaultUsageReport->new_from_api($body)->store;
|
||||
|
||||
$c->res->headers->location( $c->req->url->to_string . '/'
|
||||
. $default_report->erm_default_usage_report_id );
|
||||
$c->res->headers->location(
|
||||
$c->req->url->to_string . '/' . $default_report->erm_default_usage_report_id );
|
||||
return $c->render(
|
||||
status => 201,
|
||||
openapi => $default_report->to_api
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
catch {
|
||||
} catch {
|
||||
|
||||
my $to_api_mapping = Koha::ERM::DefaultUsageReport->new->to_api_mapping;
|
||||
my $to_api_mapping = Koha::ERM::EUsage::DefaultUsageReport->new->to_api_mapping;
|
||||
|
||||
if ( blessed $_ ) {
|
||||
if ( $_->isa('Koha::Exceptions::Object::DuplicateID') ) {
|
||||
return $c->render(
|
||||
status => 409,
|
||||
openapi =>
|
||||
{ error => $_->error, conflict => $_->duplicate_id }
|
||||
openapi => { error => $_->error, conflict => $_->duplicate_id }
|
||||
);
|
||||
}
|
||||
elsif ( $_->isa('Koha::Exceptions::Object::FKConstraint') ) {
|
||||
} elsif ( $_->isa('Koha::Exceptions::Object::FKConstraint') ) {
|
||||
return $c->render(
|
||||
status => 400,
|
||||
openapi => {
|
||||
error => "Given "
|
||||
. $to_api_mapping->{ $_->broken_fk }
|
||||
. " does not exist"
|
||||
}
|
||||
openapi => { error => "Given " . $to_api_mapping->{ $_->broken_fk } . " does not exist" }
|
||||
);
|
||||
}
|
||||
elsif ( $_->isa('Koha::Exceptions::BadParameter') ) {
|
||||
} elsif ( $_->isa('Koha::Exceptions::BadParameter') ) {
|
||||
return $c->render(
|
||||
status => 400,
|
||||
openapi => {
|
||||
error => "Given "
|
||||
. $to_api_mapping->{ $_->parameter }
|
||||
. " does not exist"
|
||||
}
|
||||
openapi => { error => "Given " . $to_api_mapping->{ $_->parameter } . " does not exist" }
|
||||
);
|
||||
}
|
||||
elsif ( $_->isa('Koha::Exceptions::PayloadTooLarge') ) {
|
||||
} elsif ( $_->isa('Koha::Exceptions::PayloadTooLarge') ) {
|
||||
return $c->render(
|
||||
status => 413,
|
||||
openapi => { error => $_->error }
|
||||
|
|
@ -123,17 +107,15 @@ sub add {
|
|||
|
||||
=head3 update
|
||||
|
||||
Controller function that handles updating a Koha::ERM::DefaultUsageReport object
|
||||
Controller function that handles updating a Koha::ERM::EUsage::DefaultUsageReport object
|
||||
|
||||
=cut
|
||||
|
||||
sub update {
|
||||
my $c = shift->openapi->valid_input or return;
|
||||
|
||||
my $default_report_id =
|
||||
$c->validation->param('erm_default_usage_report_id');
|
||||
my $default_report =
|
||||
Koha::ERM::DefaultUsageReports->find($default_report_id);
|
||||
my $default_report_id = $c->validation->param('erm_default_usage_report_id');
|
||||
my $default_report = Koha::ERM::EUsage::DefaultUsageReports->find($default_report_id);
|
||||
|
||||
unless ($default_report) {
|
||||
return $c->render(
|
||||
|
|
@ -150,40 +132,29 @@ sub update {
|
|||
|
||||
$default_report->set_from_api($body)->store;
|
||||
|
||||
$c->res->headers->location( $c->req->url->to_string . '/'
|
||||
. $default_report->erm_default_usage_report_id );
|
||||
$c->res->headers->location(
|
||||
$c->req->url->to_string . '/' . $default_report->erm_default_usage_report_id );
|
||||
return $c->render(
|
||||
status => 200,
|
||||
openapi => $default_report->to_api
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
catch {
|
||||
my $to_api_mapping = Koha::ERM::DefaultUsageReport->new->to_api_mapping;
|
||||
} catch {
|
||||
my $to_api_mapping = Koha::ERM::EUsage::DefaultUsageReport->new->to_api_mapping;
|
||||
|
||||
if ( blessed $_ ) {
|
||||
if ( $_->isa('Koha::Exceptions::Object::FKConstraint') ) {
|
||||
return $c->render(
|
||||
status => 400,
|
||||
openapi => {
|
||||
error => "Given "
|
||||
. $to_api_mapping->{ $_->broken_fk }
|
||||
. " does not exist"
|
||||
}
|
||||
openapi => { error => "Given " . $to_api_mapping->{ $_->broken_fk } . " does not exist" }
|
||||
);
|
||||
}
|
||||
elsif ( $_->isa('Koha::Exceptions::BadParameter') ) {
|
||||
} elsif ( $_->isa('Koha::Exceptions::BadParameter') ) {
|
||||
return $c->render(
|
||||
status => 400,
|
||||
openapi => {
|
||||
error => "Given "
|
||||
. $to_api_mapping->{ $_->parameter }
|
||||
. " does not exist"
|
||||
}
|
||||
openapi => { error => "Given " . $to_api_mapping->{ $_->parameter } . " does not exist" }
|
||||
);
|
||||
}
|
||||
elsif ( $_->isa('Koha::Exceptions::PayloadTooLarge') ) {
|
||||
} elsif ( $_->isa('Koha::Exceptions::PayloadTooLarge') ) {
|
||||
return $c->render(
|
||||
status => 413,
|
||||
openapi => { error => $_->error }
|
||||
|
|
@ -202,10 +173,8 @@ sub update {
|
|||
sub delete {
|
||||
my $c = shift->openapi->valid_input or return;
|
||||
|
||||
my $default_report_id =
|
||||
$c->validation->param('erm_default_usage_report_id');
|
||||
my $default_report =
|
||||
Koha::ERM::DefaultUsageReports->find($default_report_id);
|
||||
my $default_report_id = $c->validation->param('erm_default_usage_report_id');
|
||||
my $default_report = Koha::ERM::EUsage::DefaultUsageReports->find($default_report_id);
|
||||
unless ($default_report) {
|
||||
return $c->render(
|
||||
status => 404,
|
||||
|
|
@ -219,8 +188,7 @@ sub delete {
|
|||
status => 204,
|
||||
openapi => q{}
|
||||
);
|
||||
}
|
||||
catch {
|
||||
} catch {
|
||||
$c->unhandled_exception($_);
|
||||
};
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package Koha::REST::V1::ERM::SushiServices;
|
||||
package Koha::REST::V1::ERM::EUsage::SushiServices;
|
||||
|
||||
# Copyright 2023 PTFS Europe
|
||||
|
||||
|
|
@ -43,13 +43,11 @@ sub get {
|
|||
my $json = JSON->new;
|
||||
|
||||
my @query_params_array =
|
||||
map { $_ ? $json->decode($_) : () } @{ $args->{q} };
|
||||
map { $_ ? $json->decode($_) : () } @{ $args->{q} };
|
||||
|
||||
my $service_url = $query_params_array[0]->{url};
|
||||
|
||||
my $request = HTTP::Request->new(
|
||||
GET => $service_url
|
||||
);
|
||||
my $request = HTTP::Request->new( GET => $service_url );
|
||||
|
||||
my $ua = LWP::UserAgent->new;
|
||||
my $response = $ua->simple_request($request);
|
||||
|
|
@ -61,8 +59,7 @@ sub get {
|
|||
for my $r (@$result) {
|
||||
$message .= $r->{message};
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$message = $result->{message} || $result->{Message} || q{};
|
||||
if ( $result->{errors} ) {
|
||||
for my $e ( @{ $result->{errors} } ) {
|
||||
|
|
@ -71,23 +68,20 @@ sub get {
|
|||
}
|
||||
}
|
||||
warn sprintf "ERROR - Counter registry API %s returned %s - %s\n",
|
||||
$service_url,
|
||||
$response->code, $message;
|
||||
$service_url,
|
||||
$response->code, $message;
|
||||
if ( $response->code == 404 ) {
|
||||
Koha::Exceptions::ObjectNotFound->throw($message);
|
||||
}
|
||||
elsif ( $response->code == 401 ) {
|
||||
} elsif ( $response->code == 401 ) {
|
||||
Koha::Exceptions::Authorization::Unauthorized->throw($message);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
die sprintf
|
||||
"ERROR requesting Counter registry API\n%s\ncode %s: %s\n",
|
||||
$service_url,
|
||||
$response->code,
|
||||
$message;
|
||||
"ERROR requesting Counter registry API\n%s\ncode %s: %s\n",
|
||||
$service_url,
|
||||
$response->code,
|
||||
$message;
|
||||
}
|
||||
}
|
||||
elsif ( $response->code == 204 ) { # No content
|
||||
} elsif ( $response->code == 204 ) { # No content
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package Koha::REST::V1::ERM::UsageDataProviders;
|
||||
package Koha::REST::V1::ERM::EUsage::UsageDataProviders;
|
||||
|
||||
# Copyright 2023 PTFS Europe
|
||||
|
||||
|
|
@ -22,8 +22,8 @@ use Modern::Perl;
|
|||
use MIME::Base64 qw( decode_base64 );
|
||||
use Mojo::Base 'Mojolicious::Controller';
|
||||
|
||||
use Koha::ERM::UsageDataProviders;
|
||||
use Koha::ERM::MonthlyUsages;
|
||||
use Koha::ERM::EUsage::UsageDataProviders;
|
||||
use Koha::ERM::EUsage::MonthlyUsages;
|
||||
|
||||
use Scalar::Util qw( blessed );
|
||||
use Try::Tiny qw( catch try );
|
||||
|
|
@ -41,60 +41,66 @@ sub list {
|
|||
use Data::Dumper;
|
||||
|
||||
return try {
|
||||
my $usage_data_providers_set = Koha::ERM::UsageDataProviders->new;
|
||||
my $usage_data_providers =
|
||||
$c->objects->search($usage_data_providers_set);
|
||||
my $usage_data_providers_set = Koha::ERM::EUsage::UsageDataProviders->new;
|
||||
my $usage_data_providers = $c->objects->search($usage_data_providers_set);
|
||||
if ( $c->validation->output->{"x-koha-embed"}[0]
|
||||
&& $c->validation->output->{"x-koha-embed"}[0] eq 'counter_files' )
|
||||
{
|
||||
foreach my $provider (@$usage_data_providers) {
|
||||
my $title_dates = _get_earliest_and_latest_dates( 'TR',
|
||||
$provider->{erm_usage_data_provider_id} );
|
||||
my $title_dates = _get_earliest_and_latest_dates(
|
||||
'TR',
|
||||
$provider->{erm_usage_data_provider_id}
|
||||
);
|
||||
$provider->{earliest_title} =
|
||||
$title_dates->{earliest_date}
|
||||
? $title_dates->{earliest_date}
|
||||
: '';
|
||||
$title_dates->{earliest_date}
|
||||
? $title_dates->{earliest_date}
|
||||
: '';
|
||||
$provider->{latest_title} =
|
||||
$title_dates->{latest_date}
|
||||
? $title_dates->{latest_date}
|
||||
: '';
|
||||
$title_dates->{latest_date}
|
||||
? $title_dates->{latest_date}
|
||||
: '';
|
||||
|
||||
my $platform_dates = _get_earliest_and_latest_dates( 'PR',
|
||||
$provider->{erm_usage_data_provider_id} );
|
||||
my $platform_dates = _get_earliest_and_latest_dates(
|
||||
'PR',
|
||||
$provider->{erm_usage_data_provider_id}
|
||||
);
|
||||
$provider->{earliest_platform} =
|
||||
$platform_dates->{earliest_date}
|
||||
? $platform_dates->{earliest_date}
|
||||
: '';
|
||||
$platform_dates->{earliest_date}
|
||||
? $platform_dates->{earliest_date}
|
||||
: '';
|
||||
$provider->{latest_platform} =
|
||||
$platform_dates->{latest_date}
|
||||
? $platform_dates->{latest_date}
|
||||
: '';
|
||||
$platform_dates->{latest_date}
|
||||
? $platform_dates->{latest_date}
|
||||
: '';
|
||||
|
||||
my $item_dates = _get_earliest_and_latest_dates( 'IR',
|
||||
$provider->{erm_usage_data_provider_id} );
|
||||
my $item_dates = _get_earliest_and_latest_dates(
|
||||
'IR',
|
||||
$provider->{erm_usage_data_provider_id}
|
||||
);
|
||||
$provider->{earliest_item} =
|
||||
$item_dates->{earliest_date}
|
||||
? $item_dates->{earliest_date}
|
||||
: '';
|
||||
$item_dates->{earliest_date}
|
||||
? $item_dates->{earliest_date}
|
||||
: '';
|
||||
$provider->{latest_item} =
|
||||
$item_dates->{latest_date} ? $item_dates->{latest_date} : '';
|
||||
$item_dates->{latest_date} ? $item_dates->{latest_date} : '';
|
||||
|
||||
my $database_dates = _get_earliest_and_latest_dates( 'DR',
|
||||
$provider->{erm_usage_data_provider_id} );
|
||||
my $database_dates = _get_earliest_and_latest_dates(
|
||||
'DR',
|
||||
$provider->{erm_usage_data_provider_id}
|
||||
);
|
||||
$provider->{earliest_database} =
|
||||
$database_dates->{earliest_date}
|
||||
? $database_dates->{earliest_date}
|
||||
: '';
|
||||
$database_dates->{earliest_date}
|
||||
? $database_dates->{earliest_date}
|
||||
: '';
|
||||
$provider->{latest_database} =
|
||||
$database_dates->{latest_date}
|
||||
? $database_dates->{latest_date}
|
||||
: '';
|
||||
$database_dates->{latest_date}
|
||||
? $database_dates->{latest_date}
|
||||
: '';
|
||||
}
|
||||
}
|
||||
|
||||
return $c->render( status => 200, openapi => $usage_data_providers );
|
||||
}
|
||||
catch {
|
||||
} catch {
|
||||
$c->unhandled_exception($_);
|
||||
};
|
||||
|
||||
|
|
@ -102,7 +108,7 @@ sub list {
|
|||
|
||||
=head3 get
|
||||
|
||||
Controller function that handles retrieving a single Koha::ERM::UsageDataProvider object
|
||||
Controller function that handles retrieving a single Koha::ERM::EUsage::UsageDataProvider object
|
||||
|
||||
=cut
|
||||
|
||||
|
|
@ -110,11 +116,11 @@ sub get {
|
|||
my $c = shift->openapi->valid_input or return;
|
||||
|
||||
return try {
|
||||
my $usage_data_provider_id =
|
||||
$c->validation->param('erm_usage_data_provider_id');
|
||||
my $usage_data_provider =
|
||||
$c->objects->find( Koha::ERM::UsageDataProviders->search,
|
||||
$usage_data_provider_id );
|
||||
my $usage_data_provider_id = $c->validation->param('erm_usage_data_provider_id');
|
||||
my $usage_data_provider = $c->objects->find(
|
||||
Koha::ERM::EUsage::UsageDataProviders->search,
|
||||
$usage_data_provider_id
|
||||
);
|
||||
|
||||
unless ($usage_data_provider) {
|
||||
return $c->render(
|
||||
|
|
@ -127,15 +133,14 @@ sub get {
|
|||
status => 200,
|
||||
openapi => $usage_data_provider
|
||||
);
|
||||
}
|
||||
catch {
|
||||
} catch {
|
||||
$c->unhandled_exception($_);
|
||||
};
|
||||
}
|
||||
|
||||
=head3 add
|
||||
|
||||
Controller function that handles adding a new Koha::ERM::UsageDataProvider object
|
||||
Controller function that handles adding a new Koha::ERM::EUsage::UsageDataProvider object
|
||||
|
||||
=cut
|
||||
|
||||
|
|
@ -148,51 +153,37 @@ sub add {
|
|||
|
||||
my $body = $c->validation->param('body');
|
||||
|
||||
my $usage_data_provider =
|
||||
Koha::ERM::UsageDataProvider->new_from_api($body)->store;
|
||||
my $usage_data_provider = Koha::ERM::EUsage::UsageDataProvider->new_from_api($body)->store;
|
||||
|
||||
$c->res->headers->location( $c->req->url->to_string . '/'
|
||||
. $usage_data_provider->erm_usage_data_provider_id );
|
||||
$c->res->headers->location(
|
||||
$c->req->url->to_string . '/' . $usage_data_provider->erm_usage_data_provider_id );
|
||||
return $c->render(
|
||||
status => 201,
|
||||
openapi => $usage_data_provider->to_api
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
catch {
|
||||
} catch {
|
||||
|
||||
my $to_api_mapping = Koha::ERM::UsageDataProvider->new->to_api_mapping;
|
||||
my $to_api_mapping = Koha::ERM::EUsage::UsageDataProvider->new->to_api_mapping;
|
||||
|
||||
if ( blessed $_ ) {
|
||||
if ( $_->isa('Koha::Exceptions::Object::DuplicateID') ) {
|
||||
return $c->render(
|
||||
status => 409,
|
||||
openapi =>
|
||||
{ error => $_->error, conflict => $_->duplicate_id }
|
||||
openapi => { error => $_->error, conflict => $_->duplicate_id }
|
||||
);
|
||||
}
|
||||
elsif ( $_->isa('Koha::Exceptions::Object::FKConstraint') ) {
|
||||
} elsif ( $_->isa('Koha::Exceptions::Object::FKConstraint') ) {
|
||||
return $c->render(
|
||||
status => 400,
|
||||
openapi => {
|
||||
error => "Given "
|
||||
. $to_api_mapping->{ $_->broken_fk }
|
||||
. " does not exist"
|
||||
}
|
||||
openapi => { error => "Given " . $to_api_mapping->{ $_->broken_fk } . " does not exist" }
|
||||
);
|
||||
}
|
||||
elsif ( $_->isa('Koha::Exceptions::BadParameter') ) {
|
||||
} elsif ( $_->isa('Koha::Exceptions::BadParameter') ) {
|
||||
return $c->render(
|
||||
status => 400,
|
||||
openapi => {
|
||||
error => "Given "
|
||||
. $to_api_mapping->{ $_->parameter }
|
||||
. " does not exist"
|
||||
}
|
||||
openapi => { error => "Given " . $to_api_mapping->{ $_->parameter } . " does not exist" }
|
||||
);
|
||||
}
|
||||
elsif ( $_->isa('Koha::Exceptions::PayloadTooLarge') ) {
|
||||
} elsif ( $_->isa('Koha::Exceptions::PayloadTooLarge') ) {
|
||||
return $c->render(
|
||||
status => 413,
|
||||
openapi => { error => $_->error }
|
||||
|
|
@ -206,17 +197,15 @@ sub add {
|
|||
|
||||
=head3 update
|
||||
|
||||
Controller function that handles updating a Koha::ERM::UsageDataProvider object
|
||||
Controller function that handles updating a Koha::ERM::EUsage::UsageDataProvider object
|
||||
|
||||
=cut
|
||||
|
||||
sub update {
|
||||
my $c = shift->openapi->valid_input or return;
|
||||
|
||||
my $usage_data_provider_id =
|
||||
$c->validation->param('erm_usage_data_provider_id');
|
||||
my $usage_data_provider =
|
||||
Koha::ERM::UsageDataProviders->find($usage_data_provider_id);
|
||||
my $usage_data_provider_id = $c->validation->param('erm_usage_data_provider_id');
|
||||
my $usage_data_provider = Koha::ERM::EUsage::UsageDataProviders->find($usage_data_provider_id);
|
||||
|
||||
unless ($usage_data_provider) {
|
||||
return $c->render(
|
||||
|
|
@ -233,40 +222,29 @@ sub update {
|
|||
|
||||
$usage_data_provider->set_from_api($body)->store;
|
||||
|
||||
$c->res->headers->location( $c->req->url->to_string . '/'
|
||||
. $usage_data_provider->erm_usage_data_provider_id );
|
||||
$c->res->headers->location(
|
||||
$c->req->url->to_string . '/' . $usage_data_provider->erm_usage_data_provider_id );
|
||||
return $c->render(
|
||||
status => 200,
|
||||
openapi => $usage_data_provider->to_api
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
catch {
|
||||
my $to_api_mapping = Koha::ERM::UsageDataProvider->new->to_api_mapping;
|
||||
} catch {
|
||||
my $to_api_mapping = Koha::ERM::EUsage::UsageDataProvider->new->to_api_mapping;
|
||||
|
||||
if ( blessed $_ ) {
|
||||
if ( $_->isa('Koha::Exceptions::Object::FKConstraint') ) {
|
||||
return $c->render(
|
||||
status => 400,
|
||||
openapi => {
|
||||
error => "Given "
|
||||
. $to_api_mapping->{ $_->broken_fk }
|
||||
. " does not exist"
|
||||
}
|
||||
openapi => { error => "Given " . $to_api_mapping->{ $_->broken_fk } . " does not exist" }
|
||||
);
|
||||
}
|
||||
elsif ( $_->isa('Koha::Exceptions::BadParameter') ) {
|
||||
} elsif ( $_->isa('Koha::Exceptions::BadParameter') ) {
|
||||
return $c->render(
|
||||
status => 400,
|
||||
openapi => {
|
||||
error => "Given "
|
||||
. $to_api_mapping->{ $_->parameter }
|
||||
. " does not exist"
|
||||
}
|
||||
openapi => { error => "Given " . $to_api_mapping->{ $_->parameter } . " does not exist" }
|
||||
);
|
||||
}
|
||||
elsif ( $_->isa('Koha::Exceptions::PayloadTooLarge') ) {
|
||||
} elsif ( $_->isa('Koha::Exceptions::PayloadTooLarge') ) {
|
||||
return $c->render(
|
||||
status => 413,
|
||||
openapi => { error => $_->error }
|
||||
|
|
@ -285,10 +263,8 @@ sub update {
|
|||
sub delete {
|
||||
my $c = shift->openapi->valid_input or return;
|
||||
|
||||
my $usage_data_provider_id =
|
||||
$c->validation->param('erm_usage_data_provider_id');
|
||||
my $usage_data_provider =
|
||||
Koha::ERM::UsageDataProviders->find($usage_data_provider_id);
|
||||
my $usage_data_provider_id = $c->validation->param('erm_usage_data_provider_id');
|
||||
my $usage_data_provider = Koha::ERM::EUsage::UsageDataProviders->find($usage_data_provider_id);
|
||||
unless ($usage_data_provider) {
|
||||
return $c->render(
|
||||
status => 404,
|
||||
|
|
@ -302,8 +278,7 @@ sub delete {
|
|||
status => 204,
|
||||
openapi => q{}
|
||||
);
|
||||
}
|
||||
catch {
|
||||
} catch {
|
||||
$c->unhandled_exception($_);
|
||||
};
|
||||
}
|
||||
|
|
@ -325,20 +300,17 @@ sub process_COUNTER_file {
|
|||
my $body = $c->validation->param('body');
|
||||
|
||||
my $file_content =
|
||||
defined( $body->{file_content} )
|
||||
? decode_base64( $body->{file_content} )
|
||||
: "";
|
||||
defined( $body->{file_content} )
|
||||
? decode_base64( $body->{file_content} )
|
||||
: "";
|
||||
|
||||
# Validate the file_content without storing, it'll throw an exception if fail
|
||||
my $counter_file_validation =
|
||||
Koha::ERM::CounterFile->new(
|
||||
{ file_content => $file_content } );
|
||||
# Validate the file_content without storing, it'll throw an exception if fail
|
||||
my $counter_file_validation = Koha::ERM::EUsage::CounterFile->new( { file_content => $file_content } );
|
||||
$counter_file_validation->validate;
|
||||
|
||||
# Validation was successful, enqueue the job
|
||||
my $udprovider =
|
||||
Koha::ERM::UsageDataProviders->find(
|
||||
$c->validation->param('erm_usage_data_provider_id') );
|
||||
Koha::ERM::EUsage::UsageDataProviders->find( $c->validation->param('erm_usage_data_provider_id') );
|
||||
|
||||
my $jobs = $udprovider->enqueue_counter_file_processing_job(
|
||||
{
|
||||
|
|
@ -352,50 +324,32 @@ sub process_COUNTER_file {
|
|||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
catch {
|
||||
} catch {
|
||||
|
||||
my $to_api_mapping = Koha::ERM::CounterFile->new->to_api_mapping;
|
||||
my $to_api_mapping = Koha::ERM::EUsage::CounterFile->new->to_api_mapping;
|
||||
|
||||
if ( blessed $_ ) {
|
||||
if ( $_->isa('Koha::Exceptions::Object::DuplicateID') ) {
|
||||
return $c->render(
|
||||
status => 409,
|
||||
openapi =>
|
||||
{ error => $_->error, conflict => $_->duplicate_id }
|
||||
openapi => { error => $_->error, conflict => $_->duplicate_id }
|
||||
);
|
||||
}
|
||||
elsif ( $_->isa('Koha::Exceptions::Object::FKConstraint') ) {
|
||||
} elsif ( $_->isa('Koha::Exceptions::Object::FKConstraint') ) {
|
||||
return $c->render(
|
||||
status => 400,
|
||||
openapi => {
|
||||
error => "Given "
|
||||
. $to_api_mapping->{ $_->broken_fk }
|
||||
. " does not exist"
|
||||
}
|
||||
openapi => { error => "Given " . $to_api_mapping->{ $_->broken_fk } . " does not exist" }
|
||||
);
|
||||
}
|
||||
elsif ( $_->isa('Koha::Exceptions::BadParameter') ) {
|
||||
} elsif ( $_->isa('Koha::Exceptions::BadParameter') ) {
|
||||
return $c->render(
|
||||
status => 400,
|
||||
openapi => {
|
||||
error => "Given "
|
||||
. $to_api_mapping->{ $_->parameter }
|
||||
. " does not exist"
|
||||
}
|
||||
openapi => { error => "Given " . $to_api_mapping->{ $_->parameter } . " does not exist" }
|
||||
);
|
||||
}
|
||||
elsif ( $_->isa('Koha::Exceptions::PayloadTooLarge') ) {
|
||||
} elsif ( $_->isa('Koha::Exceptions::PayloadTooLarge') ) {
|
||||
return $c->render(
|
||||
status => 413,
|
||||
openapi => { error => $_->error }
|
||||
);
|
||||
}
|
||||
elsif (
|
||||
$_->isa(
|
||||
'Koha::Exceptions::ERM::CounterFile::UnsupportedRelease')
|
||||
)
|
||||
{
|
||||
} elsif ( $_->isa('Koha::Exceptions::ERM::EUsage::CounterFile::UnsupportedRelease') ) {
|
||||
return $c->render(
|
||||
status => 400,
|
||||
openapi => { error => $_->description }
|
||||
|
|
@ -428,8 +382,7 @@ sub process_SUSHI_response {
|
|||
);
|
||||
}
|
||||
|
||||
my $udprovider = Koha::ERM::UsageDataProviders->find(
|
||||
$c->validation->param('erm_usage_data_provider_id') );
|
||||
my $udprovider = Koha::ERM::EUsage::UsageDataProviders->find( $c->validation->param('erm_usage_data_provider_id') );
|
||||
|
||||
unless ($udprovider) {
|
||||
return $c->render(
|
||||
|
|
@ -450,8 +403,7 @@ sub process_SUSHI_response {
|
|||
status => 200,
|
||||
openapi => { jobs => [ @{$jobs} ] }
|
||||
);
|
||||
}
|
||||
catch {
|
||||
} catch {
|
||||
$c->unhandled_exception($_);
|
||||
};
|
||||
}
|
||||
|
|
@ -463,8 +415,7 @@ sub process_SUSHI_response {
|
|||
sub test_connection {
|
||||
my $c = shift->openapi->valid_input or return;
|
||||
|
||||
my $udprovider = Koha::ERM::UsageDataProviders->find(
|
||||
$c->validation->param('erm_usage_data_provider_id') );
|
||||
my $udprovider = Koha::ERM::EUsage::UsageDataProviders->find( $c->validation->param('erm_usage_data_provider_id') );
|
||||
|
||||
unless ($udprovider) {
|
||||
return $c->render(
|
||||
|
|
@ -478,8 +429,7 @@ sub test_connection {
|
|||
status => 200,
|
||||
openapi => $service_active
|
||||
);
|
||||
}
|
||||
catch {
|
||||
} catch {
|
||||
$c->unhandled_exception($_);
|
||||
};
|
||||
}
|
||||
|
|
@ -491,49 +441,43 @@ sub test_connection {
|
|||
sub _get_earliest_and_latest_dates {
|
||||
my ( $report_type, $id ) = @_;
|
||||
|
||||
my @years = Koha::ERM::MonthlyUsages->search(
|
||||
{
|
||||
my @years = Koha::ERM::EUsage::MonthlyUsages->search(
|
||||
{
|
||||
usage_data_provider_id => $id,
|
||||
report_type => { -like => "%$report_type%" }
|
||||
},
|
||||
report_type => { -like => "%$report_type%" }
|
||||
},
|
||||
{
|
||||
columns => [
|
||||
{ earliestYear => { min => "year" } },
|
||||
{ latestYear => { max => "year" } },
|
||||
{ latestYear => { max => "year" } },
|
||||
]
|
||||
}
|
||||
)->unblessed;
|
||||
if($years[0][0]->{earliestYear}) {
|
||||
my @earliest_month = Koha::ERM::MonthlyUsages->search(
|
||||
{
|
||||
usage_data_provider_id => $id,
|
||||
report_type => { -like => "%$report_type%" },
|
||||
year => $years[0][0]->{earliestYear},
|
||||
},
|
||||
if ( $years[0][0]->{earliestYear} ) {
|
||||
my @earliest_month = Koha::ERM::EUsage::MonthlyUsages->search(
|
||||
{
|
||||
columns => [
|
||||
{ month => { min => "month" } },
|
||||
]
|
||||
}
|
||||
usage_data_provider_id => $id,
|
||||
report_type => { -like => "%$report_type%" },
|
||||
year => $years[0][0]->{earliestYear},
|
||||
},
|
||||
{ columns => [ { month => { min => "month" } }, ] }
|
||||
)->unblessed;
|
||||
my @latest_month = Koha::ERM::MonthlyUsages->search(
|
||||
{
|
||||
usage_data_provider_id => $id,
|
||||
report_type => { -like => "%$report_type%" },
|
||||
year => $years[0][0]->{latestYear},
|
||||
},
|
||||
my @latest_month = Koha::ERM::EUsage::MonthlyUsages->search(
|
||||
{
|
||||
columns => [
|
||||
{ month => { max => "month" } },
|
||||
]
|
||||
}
|
||||
usage_data_provider_id => $id,
|
||||
report_type => { -like => "%$report_type%" },
|
||||
year => $years[0][0]->{latestYear},
|
||||
},
|
||||
{ columns => [ { month => { max => "month" } }, ] }
|
||||
)->unblessed;
|
||||
|
||||
$earliest_month[0][0]->{month} = _format_month("0$earliest_month[0][0]->{month}");
|
||||
$latest_month[0][0]->{month} = _format_month("0$latest_month[0][0]->{month}");
|
||||
$earliest_month[0][0]->{month} =
|
||||
_format_month("0$earliest_month[0][0]->{month}");
|
||||
$latest_month[0][0]->{month} =
|
||||
_format_month("0$latest_month[0][0]->{month}");
|
||||
|
||||
my $earliest_date = "$years[0][0]->{earliestYear}-$earliest_month[0][0]->{month}";
|
||||
my $latest_date = "$years[0][0]->{latestYear}-$latest_month[0][0]->{month}";
|
||||
my $latest_date = "$years[0][0]->{latestYear}-$latest_month[0][0]->{month}";
|
||||
|
||||
return {
|
||||
earliest_date => $earliest_date,
|
||||
|
|
@ -552,7 +496,7 @@ sub _get_earliest_and_latest_dates {
|
|||
=cut
|
||||
|
||||
sub _format_month {
|
||||
my ( $month ) = @_;
|
||||
my ($month) = @_;
|
||||
|
||||
$month = length($month) eq 2 ? $month : "0$month";
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package Koha::REST::V1::ERM::UsageDatabases;
|
||||
package Koha::REST::V1::ERM::EUsage::UsageDatabases;
|
||||
|
||||
# Copyright 2023 PTFS Europe
|
||||
|
||||
|
|
@ -22,7 +22,7 @@ use Modern::Perl;
|
|||
use Mojo::Base 'Mojolicious::Controller';
|
||||
use Module::Load qw( load );
|
||||
|
||||
use Koha::ERM::UsageDatabases;
|
||||
use Koha::ERM::EUsage::UsageDatabases;
|
||||
|
||||
use Clone qw( clone );
|
||||
use Scalar::Util qw( blessed );
|
||||
|
|
@ -41,11 +41,10 @@ sub list {
|
|||
my $c = shift->openapi->valid_input or return;
|
||||
|
||||
return try {
|
||||
my $usage_databases_set = Koha::ERM::UsageDatabases->new;
|
||||
my $usage_databases_set = Koha::ERM::EUsage::UsageDatabases->new;
|
||||
my $usage_databases = $c->objects->search($usage_databases_set);
|
||||
return $c->render( status => 200, openapi => $usage_databases );
|
||||
}
|
||||
catch {
|
||||
} catch {
|
||||
$c->unhandled_exception($_);
|
||||
};
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package Koha::REST::V1::ERM::UsageItems;
|
||||
package Koha::REST::V1::ERM::EUsage::UsageItems;
|
||||
|
||||
# Copyright 2023 PTFS Europe
|
||||
|
||||
|
|
@ -22,7 +22,7 @@ use Modern::Perl;
|
|||
use Mojo::Base 'Mojolicious::Controller';
|
||||
use Module::Load qw( load );
|
||||
|
||||
use Koha::ERM::UsageItems;
|
||||
use Koha::ERM::EUsage::UsageItems;
|
||||
|
||||
use Clone qw( clone );
|
||||
use Scalar::Util qw( blessed );
|
||||
|
|
@ -41,11 +41,10 @@ sub list {
|
|||
my $c = shift->openapi->valid_input or return;
|
||||
|
||||
return try {
|
||||
my $usage_items_set = Koha::ERM::UsageItems->new;
|
||||
my $usage_items_set = Koha::ERM::EUsage::UsageItems->new;
|
||||
my $usage_items = $c->objects->search($usage_items_set);
|
||||
return $c->render( status => 200, openapi => $usage_items );
|
||||
}
|
||||
catch {
|
||||
} catch {
|
||||
$c->unhandled_exception($_);
|
||||
};
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package Koha::REST::V1::ERM::UsagePlatforms;
|
||||
package Koha::REST::V1::ERM::EUsage::UsagePlatforms;
|
||||
|
||||
# Copyright 2023 PTFS Europe
|
||||
|
||||
|
|
@ -22,7 +22,7 @@ use Modern::Perl;
|
|||
use Mojo::Base 'Mojolicious::Controller';
|
||||
use Module::Load qw( load );
|
||||
|
||||
use Koha::ERM::UsagePlatforms;
|
||||
use Koha::ERM::EUsage::UsagePlatforms;
|
||||
|
||||
use Clone qw( clone );
|
||||
use Scalar::Util qw( blessed );
|
||||
|
|
@ -41,11 +41,10 @@ sub list {
|
|||
my $c = shift->openapi->valid_input or return;
|
||||
|
||||
return try {
|
||||
my $usage_platforms_set = Koha::ERM::UsagePlatforms->new;
|
||||
my $usage_platforms_set = Koha::ERM::EUsage::UsagePlatforms->new;
|
||||
my $usage_platforms = $c->objects->search($usage_platforms_set);
|
||||
return $c->render( status => 200, openapi => $usage_platforms );
|
||||
}
|
||||
catch {
|
||||
} catch {
|
||||
$c->unhandled_exception($_);
|
||||
};
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package Koha::REST::V1::ERM::UsageTitles;
|
||||
package Koha::REST::V1::ERM::EUsage::UsageTitles;
|
||||
|
||||
# Copyright 2023 PTFS Europe
|
||||
|
||||
|
|
@ -22,12 +22,12 @@ use Modern::Perl;
|
|||
use Mojo::Base 'Mojolicious::Controller';
|
||||
use Module::Load qw( load );
|
||||
|
||||
use Koha::ERM::UsageTitles;
|
||||
use Koha::ERM::UsagePlatforms;
|
||||
use Koha::ERM::UsageItems;
|
||||
use Koha::ERM::UsageDatabases;
|
||||
use Koha::ERM::UsageDataProvider;
|
||||
use Koha::ERM::UsageDataProviders;
|
||||
use Koha::ERM::EUsage::UsageTitles;
|
||||
use Koha::ERM::EUsage::UsagePlatforms;
|
||||
use Koha::ERM::EUsage::UsageItems;
|
||||
use Koha::ERM::EUsage::UsageDatabases;
|
||||
use Koha::ERM::EUsage::UsageDataProvider;
|
||||
use Koha::ERM::EUsage::UsageDataProviders;
|
||||
|
||||
use Clone qw( clone );
|
||||
use Scalar::Util qw( blessed );
|
||||
|
|
@ -46,11 +46,10 @@ sub list {
|
|||
my $c = shift->openapi->valid_input or return;
|
||||
|
||||
return try {
|
||||
my $usage_titles_set = Koha::ERM::UsageTitles->new;
|
||||
my $usage_titles_set = Koha::ERM::EUsage::UsageTitles->new;
|
||||
my $usage_titles = $c->objects->search($usage_titles_set);
|
||||
return $c->render( status => 200, openapi => $usage_titles );
|
||||
}
|
||||
catch {
|
||||
} catch {
|
||||
$c->unhandled_exception($_);
|
||||
};
|
||||
}
|
||||
|
|
@ -148,10 +148,10 @@ __PACKAGE__->belongs_to(
|
|||
|
||||
|
||||
sub koha_object_class {
|
||||
'Koha::ERM::CounterFile';
|
||||
'Koha::ERM::EUsage::CounterFile';
|
||||
}
|
||||
sub koha_objects_class {
|
||||
'Koha::ERM::CounterFiles';
|
||||
'Koha::ERM::EUsage::CounterFiles';
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -153,9 +153,9 @@ __PACKAGE__->belongs_to(
|
|||
|
||||
|
||||
sub koha_object_class {
|
||||
'Koha::ERM::CounterLog';
|
||||
'Koha::ERM::EUsage::CounterLog';
|
||||
}
|
||||
sub koha_objects_class {
|
||||
'Koha::ERM::CounterLogs';
|
||||
'Koha::ERM::EUsage::CounterLogs';
|
||||
}
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -77,10 +77,10 @@ __PACKAGE__->set_primary_key("erm_default_usage_report_id");
|
|||
# You can replace this text with custom code or comments, and it will be preserved on regeneration
|
||||
|
||||
sub koha_object_class {
|
||||
'Koha::ERM::DefaultUsageReport';
|
||||
'Koha::ERM::EUsage::DefaultUsageReport';
|
||||
}
|
||||
sub koha_objects_class {
|
||||
'Koha::ERM::DefaultUsageReports';
|
||||
'Koha::ERM::EUsage::DefaultUsageReports';
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -319,10 +319,10 @@ __PACKAGE__->has_many(
|
|||
# );
|
||||
|
||||
sub koha_object_class {
|
||||
'Koha::ERM::UsageDataProvider';
|
||||
'Koha::ERM::EUsage::UsageDataProvider';
|
||||
}
|
||||
sub koha_objects_class {
|
||||
'Koha::ERM::UsageDataProviders';
|
||||
'Koha::ERM::EUsage::UsageDataProviders';
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -155,10 +155,10 @@ __PACKAGE__->belongs_to(
|
|||
# You can replace this text with custom code or comments, and it will be preserved on regeneration
|
||||
|
||||
sub koha_object_class {
|
||||
'Koha::ERM::UsageDatabase';
|
||||
'Koha::ERM::EUsage::UsageDatabase';
|
||||
}
|
||||
|
||||
sub koha_objects_class {
|
||||
'Koha::ERM::UsageDatabases';
|
||||
'Koha::ERM::EUsage::UsageDatabases';
|
||||
}
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -145,11 +145,11 @@ __PACKAGE__->belongs_to(
|
|||
# You can replace this text with custom code or comments, and it will be preserved on regeneration
|
||||
|
||||
sub koha_object_class {
|
||||
'Koha::ERM::UsageItem';
|
||||
'Koha::ERM::EUsage::UsageItem';
|
||||
}
|
||||
|
||||
sub koha_objects_class {
|
||||
'Koha::ERM::UsageItems';
|
||||
'Koha::ERM::EUsage::UsageItems';
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -265,10 +265,10 @@ __PACKAGE__->belongs_to(
|
|||
|
||||
|
||||
sub koha_object_class {
|
||||
'Koha::ERM::MonthlyUsage';
|
||||
'Koha::ERM::EUsage::MonthlyUsage';
|
||||
}
|
||||
sub koha_objects_class {
|
||||
'Koha::ERM::MonthlyUsages';
|
||||
'Koha::ERM::EUsage::MonthlyUsages';
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -123,11 +123,11 @@ __PACKAGE__->belongs_to(
|
|||
|
||||
|
||||
sub koha_object_class {
|
||||
'Koha::ERM::UsagePlatform';
|
||||
'Koha::ERM::EUsage::UsagePlatform';
|
||||
}
|
||||
|
||||
sub koha_objects_class {
|
||||
'Koha::ERM::UsagePlatforms';
|
||||
'Koha::ERM::EUsage::UsagePlatforms';
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -203,10 +203,10 @@ __PACKAGE__->belongs_to(
|
|||
|
||||
|
||||
sub koha_object_class {
|
||||
'Koha::ERM::UsageTitle';
|
||||
'Koha::ERM::EUsage::UsageTitle';
|
||||
}
|
||||
sub koha_objects_class {
|
||||
'Koha::ERM::UsageTitles';
|
||||
'Koha::ERM::EUsage::UsageTitles';
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -256,10 +256,10 @@ __PACKAGE__->belongs_to(
|
|||
|
||||
|
||||
sub koha_object_class {
|
||||
'Koha::ERM::YearlyUsage';
|
||||
'Koha::ERM::EUsage::YearlyUsage';
|
||||
}
|
||||
sub koha_objects_class {
|
||||
'Koha::ERM::YearlyUsages';
|
||||
'Koha::ERM::EUsage::YearlyUsages';
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
---
|
||||
"/erm/counter_files/{erm_counter_files_id}/file/content":
|
||||
get:
|
||||
x-mojo-to: ERM::CounterFiles#get
|
||||
x-mojo-to: ERM::EUsage::CounterFiles#get
|
||||
operationId: downloadCounterFile
|
||||
tags:
|
||||
- counter_file
|
||||
|
|
@ -46,7 +46,7 @@
|
|||
erm: 1
|
||||
/erm/counter_files:
|
||||
get:
|
||||
x-mojo-to: ERM::CounterFiles#list
|
||||
x-mojo-to: ERM::EUsage::CounterFiles#list
|
||||
operationId: listErmCounterFiles
|
||||
tags:
|
||||
- counter_file
|
||||
|
|
@ -130,7 +130,7 @@
|
|||
erm: 1
|
||||
"/erm/counter_files/{erm_counter_files_id}":
|
||||
delete:
|
||||
x-mojo-to: ERM::CounterFiles#delete
|
||||
x-mojo-to: ERM::EUsage::CounterFiles#delete
|
||||
operationId: deleteERMCounterFiles
|
||||
tags:
|
||||
- counter_file
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
---
|
||||
/erm/counter_registry:
|
||||
get:
|
||||
x-mojo-to: ERM::CounterRegistry#list
|
||||
x-mojo-to: ERM::EUsage::CounterRegistry#list
|
||||
operationId: listCounterRegisteredPlatforms
|
||||
tags:
|
||||
- erm_counter_registry
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
"/erm/eUsage/monthly_report/{data_type}":
|
||||
get:
|
||||
x-mojo-to: ERM::CustomReports#monthly_report
|
||||
x-mojo-to: ERM::EUsage::CustomReports#monthly_report
|
||||
operationId: getERMUsageMonthlyReport
|
||||
tags:
|
||||
- usage_report
|
||||
|
|
@ -59,7 +59,7 @@
|
|||
erm: 1
|
||||
"/erm/eUsage/yearly_report/{data_type}":
|
||||
get:
|
||||
x-mojo-to: ERM::CustomReports#yearly_report
|
||||
x-mojo-to: ERM::EUsage::CustomReports#yearly_report
|
||||
operationId: getERMUsageYearlyReport
|
||||
tags:
|
||||
- usage_report
|
||||
|
|
@ -118,7 +118,7 @@
|
|||
erm: 1
|
||||
"/erm/eUsage/metric_types_report/{data_type}":
|
||||
get:
|
||||
x-mojo-to: ERM::CustomReports#metric_types_report
|
||||
x-mojo-to: ERM::EUsage::CustomReports#metric_types_report
|
||||
operationId: getERMUsageMetricTypesReport
|
||||
tags:
|
||||
- usage_report
|
||||
|
|
@ -177,7 +177,7 @@
|
|||
erm: 1
|
||||
"/erm/eUsage/provider_rollup_report/{data_type}":
|
||||
get:
|
||||
x-mojo-to: ERM::CustomReports#provider_rollup_report
|
||||
x-mojo-to: ERM::EUsage::CustomReports#provider_rollup_report
|
||||
operationId: getERMUsageProviderRollupReport
|
||||
tags:
|
||||
- usage_report
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
---
|
||||
/erm/default_usage_reports:
|
||||
get:
|
||||
x-mojo-to: ERM::DefaultUsageReports#list
|
||||
x-mojo-to: ERM::EUsage::DefaultUsageReports#list
|
||||
operationId: listErmDefaultUsageReports
|
||||
tags:
|
||||
- default_usage_report
|
||||
|
|
@ -59,7 +59,7 @@
|
|||
permissions:
|
||||
erm: 1
|
||||
post:
|
||||
x-mojo-to: ERM::DefaultUsageReports#add
|
||||
x-mojo-to: ERM::EUsage::DefaultUsageReports#add
|
||||
operationId: addErmDefaultUsageReports
|
||||
tags:
|
||||
- default_usage_report
|
||||
|
|
@ -120,7 +120,7 @@
|
|||
erm: 1
|
||||
"/erm/default_usage_reports/{erm_default_usage_report_id}":
|
||||
get:
|
||||
x-mojo-to: ERM::DefaultUsageReports#get
|
||||
x-mojo-to: ERM::EUsage::DefaultUsageReports#get
|
||||
operationId: getERMDefaultUsageReport
|
||||
tags:
|
||||
- default_usage_report
|
||||
|
|
@ -161,7 +161,7 @@
|
|||
permissions:
|
||||
erm: 1
|
||||
put:
|
||||
x-mojo-to: ERM::DefaultUsageReports#update
|
||||
x-mojo-to: ERM::EUsage::DefaultUsageReports#update
|
||||
operationId: updateERMDefaultUsageReports
|
||||
tags:
|
||||
- default_usage_report
|
||||
|
|
@ -218,7 +218,7 @@
|
|||
permissions:
|
||||
erm: 1
|
||||
delete:
|
||||
x-mojo-to: ERM::DefaultUsageReports#delete
|
||||
x-mojo-to: ERM::EUsage::DefaultUsageReports#delete
|
||||
operationId: deleteERMDefaultUsageReports
|
||||
tags:
|
||||
- default_usage_report
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
---
|
||||
/erm/sushi_service:
|
||||
get:
|
||||
x-mojo-to: ERM::SushiServices#get
|
||||
x-mojo-to: ERM::EUsage::SushiServices#get
|
||||
operationId: getSushiService
|
||||
tags:
|
||||
- erm_sushi_service
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
---
|
||||
/erm/usage_data_providers:
|
||||
get:
|
||||
x-mojo-to: ERM::UsageDataProviders#list
|
||||
x-mojo-to: ERM::EUsage::UsageDataProviders#list
|
||||
operationId: listErmUsageDataProviders
|
||||
tags:
|
||||
- usage_data_provider
|
||||
|
|
@ -129,7 +129,7 @@
|
|||
permissions:
|
||||
erm: 1
|
||||
post:
|
||||
x-mojo-to: ERM::UsageDataProviders#add
|
||||
x-mojo-to: ERM::EUsage::UsageDataProviders#add
|
||||
operationId: addErmUsageDataProviders
|
||||
tags:
|
||||
- usage_data_provider
|
||||
|
|
@ -190,7 +190,7 @@
|
|||
erm: 1
|
||||
"/erm/usage_data_providers/{erm_usage_data_provider_id}":
|
||||
get:
|
||||
x-mojo-to: ERM::UsageDataProviders#get
|
||||
x-mojo-to: ERM::EUsage::UsageDataProviders#get
|
||||
operationId: getERMUsageDataProvider
|
||||
tags:
|
||||
- usage_data_provider
|
||||
|
|
@ -242,7 +242,7 @@
|
|||
permissions:
|
||||
erm: 1
|
||||
put:
|
||||
x-mojo-to: ERM::UsageDataProviders#update
|
||||
x-mojo-to: ERM::EUsage::UsageDataProviders#update
|
||||
operationId: updateERMUsageDataProviders
|
||||
tags:
|
||||
- usage_data_provider
|
||||
|
|
@ -307,7 +307,7 @@
|
|||
permissions:
|
||||
erm: 1
|
||||
delete:
|
||||
x-mojo-to: ERM::UsageDataProviders#delete
|
||||
x-mojo-to: ERM::EUsage::UsageDataProviders#delete
|
||||
operationId: deleteERMUsageDataProviders
|
||||
tags:
|
||||
- usage_data_provider
|
||||
|
|
@ -354,7 +354,7 @@
|
|||
erm: 1
|
||||
"/erm/usage_data_providers/{erm_usage_data_provider_id}/process_SUSHI_response":
|
||||
post:
|
||||
x-mojo-to: ERM::UsageDataProviders#process_SUSHI_response
|
||||
x-mojo-to: ERM::EUsage::UsageDataProviders#process_SUSHI_response
|
||||
operationId: processSUSHICounterUsageDataProviderHarvester
|
||||
tags:
|
||||
- usage data provider harvester
|
||||
|
|
@ -408,7 +408,7 @@
|
|||
erm: 1
|
||||
"/erm/usage_data_providers/{erm_usage_data_provider_id}/process_COUNTER_file":
|
||||
post:
|
||||
x-mojo-to: ERM::UsageDataProviders#process_COUNTER_file
|
||||
x-mojo-to: ERM::EUsage::UsageDataProviders#process_COUNTER_file
|
||||
operationId: processCOUNTERFileUsageDataProviderHarvester
|
||||
tags:
|
||||
- usage data provider harvester
|
||||
|
|
@ -452,7 +452,7 @@
|
|||
erm: 1
|
||||
"/erm/usage_data_providers/{erm_usage_data_provider_id}/test_connection":
|
||||
get:
|
||||
x-mojo-to: ERM::UsageDataProviders#test_connection
|
||||
x-mojo-to: ERM::EUsage::UsageDataProviders#test_connection
|
||||
operationId: testUsageDataProviderHarvester
|
||||
tags:
|
||||
- usage data provider harvester
|
||||
|
|
@ -490,7 +490,7 @@
|
|||
erm: 1
|
||||
"/erm/usage_data_providers/report":
|
||||
get:
|
||||
x-mojo-to: ERM::UsageDataProviders#providers_report
|
||||
x-mojo-to: ERM::EUsage::UsageDataProviders#providers_report
|
||||
operationId: reportUsageDataProvider
|
||||
tags:
|
||||
- usage data provider report
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
---
|
||||
/erm/usage_databases:
|
||||
get:
|
||||
x-mojo-to: ERM::UsageDatabases#list
|
||||
x-mojo-to: ERM::EUsage::UsageDatabases#list
|
||||
operationId: listErmUsageDatabases
|
||||
tags:
|
||||
- usage_database
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
---
|
||||
/erm/usage_items:
|
||||
get:
|
||||
x-mojo-to: ERM::UsageItems#list
|
||||
x-mojo-to: ERM::EUsage::UsageItems#list
|
||||
operationId: listErmUsageItems
|
||||
tags:
|
||||
- usage_item
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
---
|
||||
/erm/usage_platforms:
|
||||
get:
|
||||
x-mojo-to: ERM::UsagePlatforms#list
|
||||
x-mojo-to: ERM::EUsage::UsagePlatforms#list
|
||||
operationId: listErmUsagePlatforms
|
||||
tags:
|
||||
- usage_platform
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
---
|
||||
/erm/usage_titles:
|
||||
get:
|
||||
x-mojo-to: ERM::UsageTitles#list
|
||||
x-mojo-to: ERM::EUsage::UsageTitles#list
|
||||
operationId: listErmUsageTitles
|
||||
tags:
|
||||
- usage_title
|
||||
|
|
|
|||
|
|
@ -18,12 +18,12 @@
|
|||
# along with Koha; if not, see <http://www.gnu.org/licenses>.
|
||||
|
||||
use Modern::Perl;
|
||||
use Getopt::Long qw( GetOptions );
|
||||
use Getopt::Long qw( GetOptions );
|
||||
use Koha::DateUtils qw( dt_from_string );
|
||||
use POSIX;
|
||||
|
||||
use Koha::Script;
|
||||
use Koha::ERM::UsageDataProviders;
|
||||
use Koha::ERM::EUsage::UsageDataProviders;
|
||||
|
||||
# Command line option values
|
||||
my $get_help = 0;
|
||||
|
|
@ -45,12 +45,12 @@ if ($get_help) {
|
|||
exit 1;
|
||||
}
|
||||
|
||||
my $udproviders = Koha::ERM::UsageDataProviders->search( { active => 1 } );
|
||||
my $udproviders = Koha::ERM::EUsage::UsageDataProviders->search( { active => 1 } );
|
||||
unless ( scalar @{ $udproviders->as_list() } ) {
|
||||
die "ERROR: No usage data providers found.";
|
||||
}
|
||||
|
||||
unless ( $begin_date ) {
|
||||
unless ($begin_date) {
|
||||
die "ERROR: Please specify a begin-date";
|
||||
}
|
||||
|
||||
|
|
@ -92,7 +92,6 @@ while ( my $udprovider = $udproviders->next ) {
|
|||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
sub debug_msg {
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ use Test::Mojo;
|
|||
use t::lib::TestBuilder;
|
||||
use t::lib::Mocks;
|
||||
|
||||
use Koha::ERM::CounterFiles;
|
||||
use Koha::ERM::EUsage::CounterFiles;
|
||||
use Koha::Database;
|
||||
|
||||
my $schema = Koha::Database->new->schema;
|
||||
|
|
@ -40,7 +40,7 @@ subtest 'list() tests' => sub {
|
|||
|
||||
$schema->storage->txn_begin;
|
||||
|
||||
Koha::ERM::CounterFiles->search->delete;
|
||||
Koha::ERM::EUsage::CounterFiles->search->delete;
|
||||
|
||||
my $librarian = $builder->build_object(
|
||||
{
|
||||
|
|
@ -68,7 +68,7 @@ subtest 'list() tests' => sub {
|
|||
->json_is( [] );
|
||||
|
||||
my $counter_file =
|
||||
$builder->build_object( { class => 'Koha::ERM::CounterFiles' } );
|
||||
$builder->build_object( { class => 'Koha::ERM::EUsage::CounterFiles' } );
|
||||
|
||||
# One counter_file created, should get returned
|
||||
$t->get_ok("//$userid:$password@/api/v1/erm/counter_files")->status_is(200)
|
||||
|
|
@ -76,7 +76,7 @@ subtest 'list() tests' => sub {
|
|||
|
||||
my $another_counter_file = $builder->build_object(
|
||||
{
|
||||
class => 'Koha::ERM::CounterFiles',
|
||||
class => 'Koha::ERM::EUsage::CounterFiles',
|
||||
}
|
||||
);
|
||||
|
||||
|
|
@ -93,7 +93,7 @@ qq~//$userid:$password@/api/v1/erm/counter_files?q=[{"me.type":{"like":"%ko%"}}]
|
|||
|
||||
my $counter_file_to_search = $builder->build_object(
|
||||
{
|
||||
class => 'Koha::ERM::CounterFiles',
|
||||
class => 'Koha::ERM::EUsage::CounterFiles',
|
||||
value => {
|
||||
type => 'koha',
|
||||
}
|
||||
|
|
@ -125,7 +125,7 @@ subtest 'get() tests' => sub {
|
|||
$schema->storage->txn_begin;
|
||||
|
||||
my $counter_file =
|
||||
$builder->build_object( { class => 'Koha::ERM::CounterFiles' } );
|
||||
$builder->build_object( { class => 'Koha::ERM::EUsage::CounterFiles' } );
|
||||
my $librarian = $builder->build_object(
|
||||
{
|
||||
class => 'Koha::Patrons',
|
||||
|
|
@ -156,7 +156,7 @@ subtest 'get() tests' => sub {
|
|||
|
||||
# Attempt to get non-existent counter_file
|
||||
my $counter_file_to_delete =
|
||||
$builder->build_object( { class => 'Koha::ERM::CounterFiles' } );
|
||||
$builder->build_object( { class => 'Koha::ERM::EUsage::CounterFiles' } );
|
||||
my $non_existent_id = $counter_file_to_delete->erm_counter_files_id;
|
||||
$counter_file_to_delete->delete;
|
||||
|
||||
|
|
@ -193,7 +193,7 @@ subtest 'delete() tests' => sub {
|
|||
my $unauth_userid = $patron->userid;
|
||||
|
||||
my $counter_file_id =
|
||||
$builder->build_object( { class => 'Koha::ERM::CounterFiles' } )
|
||||
$builder->build_object( { class => 'Koha::ERM::EUsage::CounterFiles' } )
|
||||
->erm_counter_files_id;
|
||||
|
||||
# Unauthorized attempt to delete
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ use Test::Mojo;
|
|||
use t::lib::TestBuilder;
|
||||
use t::lib::Mocks;
|
||||
|
||||
use Koha::ERM::UsageDataProviders;
|
||||
use Koha::ERM::EUsage::UsageDataProviders;
|
||||
use Koha::Database;
|
||||
|
||||
my $schema = Koha::Database->new->schema;
|
||||
|
|
@ -40,7 +40,7 @@ subtest 'list() tests' => sub {
|
|||
|
||||
$schema->storage->txn_begin;
|
||||
|
||||
Koha::ERM::UsageDataProviders->search->delete;
|
||||
Koha::ERM::EUsage::UsageDataProviders->search->delete;
|
||||
|
||||
my $librarian = $builder->build_object(
|
||||
{
|
||||
|
|
@ -87,7 +87,7 @@ subtest 'list() tests' => sub {
|
|||
|
||||
my $another_usage_data_provider = $builder->build_object(
|
||||
{
|
||||
class => 'Koha::ERM::UsageDataProviders',
|
||||
class => 'Koha::ERM::EUsage::UsageDataProviders',
|
||||
}
|
||||
);
|
||||
my $another_udp_result = { %{ $another_usage_data_provider->to_api }, %additional_fields };
|
||||
|
|
@ -108,7 +108,7 @@ subtest 'list() tests' => sub {
|
|||
|
||||
my $usage_data_provider_to_search = $builder->build_object(
|
||||
{
|
||||
class => 'Koha::ERM::UsageDataProviders',
|
||||
class => 'Koha::ERM::EUsage::UsageDataProviders',
|
||||
value => {
|
||||
name => 'koha',
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ use Test::Mojo;
|
|||
use t::lib::TestBuilder;
|
||||
use t::lib::Mocks;
|
||||
|
||||
use Koha::ERM::UsageTitles;
|
||||
use Koha::ERM::EUsage::UsageTitles;
|
||||
use Koha::Database;
|
||||
|
||||
my $schema = Koha::Database->new->schema;
|
||||
|
|
@ -40,7 +40,7 @@ subtest 'list() tests' => sub {
|
|||
|
||||
$schema->storage->txn_begin;
|
||||
|
||||
Koha::ERM::UsageTitles->search->delete;
|
||||
Koha::ERM::EUsage::UsageTitles->search->delete;
|
||||
|
||||
my $librarian = $builder->build_object(
|
||||
{
|
||||
|
|
@ -68,7 +68,7 @@ subtest 'list() tests' => sub {
|
|||
->json_is( [] );
|
||||
|
||||
my $usage_title =
|
||||
$builder->build_object( { class => 'Koha::ERM::UsageTitles' } );
|
||||
$builder->build_object( { class => 'Koha::ERM::EUsage::UsageTitles' } );
|
||||
|
||||
# One usage_title created, should get returned
|
||||
$t->get_ok("//$userid:$password@/api/v1/erm/usage_titles")->status_is(200)
|
||||
|
|
@ -76,7 +76,7 @@ subtest 'list() tests' => sub {
|
|||
|
||||
my $another_usage_title = $builder->build_object(
|
||||
{
|
||||
class => 'Koha::ERM::UsageTitles',
|
||||
class => 'Koha::ERM::EUsage::UsageTitles',
|
||||
}
|
||||
);
|
||||
|
||||
|
|
@ -93,7 +93,7 @@ qq~//$userid:$password@/api/v1/erm/usage_titles?q=[{"me.title":{"like":"%ko%"}}]
|
|||
|
||||
my $usage_title_to_search = $builder->build_object(
|
||||
{
|
||||
class => 'Koha::ERM::UsageTitles',
|
||||
class => 'Koha::ERM::EUsage::UsageTitles',
|
||||
value => {
|
||||
title => 'koha',
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue