Bug 34587: Add access_type and yop to the reports viewer
Some report types include access_type and yop headers for each usage statistics The hierarchy is as follows: yop - access_type - metric_type I.e. for each yop there are report lines for access_type and then for each access_type there are also report lines for metric types This patch adds helper functions to populate the report rows based on this hierarchy and the report data retrieved from the database 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
0a8e3e2bdc
commit
c0b449ea2a
6 changed files with 447 additions and 159 deletions
|
@ -28,9 +28,10 @@ use Koha::ERM::EUsage::UsageDatabases;
|
||||||
use Koha::ERM::EUsage::UsageDataProvider;
|
use Koha::ERM::EUsage::UsageDataProvider;
|
||||||
use Koha::ERM::EUsage::UsageDataProviders;
|
use Koha::ERM::EUsage::UsageDataProviders;
|
||||||
|
|
||||||
use Clone qw( clone );
|
use Clone qw( clone );
|
||||||
use Scalar::Util qw( blessed );
|
use Scalar::Util qw( blessed );
|
||||||
use Try::Tiny qw( catch try );
|
use Try::Tiny qw( catch try );
|
||||||
|
use List::MoreUtils qw(uniq);
|
||||||
use JSON;
|
use JSON;
|
||||||
|
|
||||||
=head1 API
|
=head1 API
|
||||||
|
@ -48,13 +49,12 @@ sub monthly_report {
|
||||||
|
|
||||||
return try {
|
return try {
|
||||||
|
|
||||||
my $args = $c->validation->output;
|
my $args = $c->param('q');
|
||||||
|
|
||||||
my @query_params_array;
|
my @query_params_array;
|
||||||
my $json = JSON->new;
|
my $json = JSON->new;
|
||||||
|
|
||||||
if ( ref( $args->{q} ) eq 'ARRAY' ) {
|
if ( ref($args) eq 'ARRAY' ) {
|
||||||
foreach my $q ( @{ $args->{q} } ) {
|
foreach my $q ( @{$args} ) {
|
||||||
push @query_params_array, $json->decode($q)
|
push @query_params_array, $json->decode($q)
|
||||||
if $q;
|
if $q;
|
||||||
}
|
}
|
||||||
|
@ -68,6 +68,10 @@ sub monthly_report {
|
||||||
Koha::ERM::EUsage::UsageDataProviders->search( {}, {} )->unblessed;
|
Koha::ERM::EUsage::UsageDataProviders->search( {}, {} )->unblessed;
|
||||||
my $metric_types =
|
my $metric_types =
|
||||||
$query_params_array[0][0]->{'erm_usage_muses.metric_type'};
|
$query_params_array[0][0]->{'erm_usage_muses.metric_type'};
|
||||||
|
my $access_types =
|
||||||
|
$query_params_array[0][0]->{'erm_usage_muses.access_type'}
|
||||||
|
? $query_params_array[0][0]->{'erm_usage_muses.access_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
|
# 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(
|
my $requested_ids = _get_correct_query_param(
|
||||||
|
@ -85,45 +89,18 @@ sub monthly_report {
|
||||||
push @{$data}, $missing_result if $missing_result;
|
push @{$data}, $missing_result if $missing_result;
|
||||||
}
|
}
|
||||||
|
|
||||||
my @report_data;
|
my $report_data = _get_report_data(
|
||||||
|
{
|
||||||
for my $data_object ( @{$data} ) {
|
data_type => $data_type,
|
||||||
|
data => $data,
|
||||||
# Add provider name rather than embed provider object
|
metric_types => $metric_types,
|
||||||
my $usage_data_provider_id = $data_object->{usage_data_provider_id};
|
access_types => $access_types,
|
||||||
my @provider_object =
|
usage_data_providers => $usage_data_providers,
|
||||||
grep { $usage_data_provider_id eq $_->{erm_usage_data_provider_id} } @{$usage_data_providers};
|
period => 'monthly'
|
||||||
my $provider_name = $provider_object[0]->{name};
|
|
||||||
|
|
||||||
# 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;
|
|
||||||
my @usage_counts =
|
|
||||||
map { $_->{usage_count} } @filtered_statistics;
|
|
||||||
my $sum =
|
|
||||||
scalar(@usage_counts) > 0
|
|
||||||
? eval join '+', @usage_counts
|
|
||||||
: 0;
|
|
||||||
|
|
||||||
my $data_object_hash = _get_object_hash(
|
|
||||||
{
|
|
||||||
data_type => $data_type,
|
|
||||||
data_object => $data_object,
|
|
||||||
statistics => \@filtered_statistics,
|
|
||||||
provider => $provider_name,
|
|
||||||
metric_type => $metric_type,
|
|
||||||
period => 'monthly',
|
|
||||||
sum => $sum
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
push @report_data, $data_object_hash;
|
|
||||||
}
|
}
|
||||||
}
|
);
|
||||||
|
|
||||||
return $c->render( status => 200, openapi => \@report_data );
|
return $c->render( status => 200, openapi => $report_data );
|
||||||
} catch {
|
} catch {
|
||||||
$c->unhandled_exception($_);
|
$c->unhandled_exception($_);
|
||||||
};
|
};
|
||||||
|
@ -140,13 +117,12 @@ sub yearly_report {
|
||||||
my $c = shift->openapi->valid_input or return;
|
my $c = shift->openapi->valid_input or return;
|
||||||
|
|
||||||
return try {
|
return try {
|
||||||
my $args = $c->validation->output;
|
my $args = $c->param('q');
|
||||||
|
|
||||||
my @query_params_array;
|
my @query_params_array;
|
||||||
my $json = JSON->new;
|
my $json = JSON->new;
|
||||||
|
|
||||||
if ( ref( $args->{q} ) eq 'ARRAY' ) {
|
if ( ref($args) eq 'ARRAY' ) {
|
||||||
foreach my $q ( @{ $args->{q} } ) {
|
foreach my $q ( @{$args} ) {
|
||||||
push @query_params_array, $json->decode($q)
|
push @query_params_array, $json->decode($q)
|
||||||
if $q;
|
if $q;
|
||||||
}
|
}
|
||||||
|
@ -176,38 +152,23 @@ sub yearly_report {
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
my $access_types =
|
||||||
|
$query_params_array[0]->{'erm_usage_yuses.access_type'}
|
||||||
|
? $query_params_array[0]->{'erm_usage_yuses.access_type'}
|
||||||
|
: ();
|
||||||
|
|
||||||
for my $data_object ( @{$data} ) {
|
my $report_data = _get_report_data(
|
||||||
|
{
|
||||||
# Add provider name rather than embed provider object
|
data_type => $data_type,
|
||||||
my $usage_data_provider_id = $data_object->{usage_data_provider_id};
|
data => $data,
|
||||||
my @provider_object =
|
metric_types => $metric_types,
|
||||||
grep { $usage_data_provider_id eq $_->{erm_usage_data_provider_id} } @{$usage_data_providers};
|
access_types => $access_types,
|
||||||
my $provider_name = $provider_object[0]->{name};
|
usage_data_providers => $usage_data_providers,
|
||||||
|
period => 'yearly'
|
||||||
# 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;
|
|
||||||
|
|
||||||
my $data_object_hash = _get_object_hash(
|
|
||||||
{
|
|
||||||
data_type => $data_type,
|
|
||||||
data_object => $data_object,
|
|
||||||
statistics => \@filtered_statistics,
|
|
||||||
provider => $provider_name,
|
|
||||||
metric_type => $metric_type,
|
|
||||||
period => 'yearly'
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
push @report_data, $data_object_hash;
|
|
||||||
}
|
}
|
||||||
}
|
);
|
||||||
|
|
||||||
return $c->render( status => 200, openapi => \@report_data );
|
return $c->render( status => 200, openapi => $report_data );
|
||||||
} catch {
|
} catch {
|
||||||
$c->unhandled_exception($_);
|
$c->unhandled_exception($_);
|
||||||
};
|
};
|
||||||
|
@ -225,13 +186,12 @@ sub metric_types_report {
|
||||||
|
|
||||||
return try {
|
return try {
|
||||||
|
|
||||||
my $args = $c->validation->output;
|
my $args = $c->param('q');
|
||||||
|
|
||||||
my @query_params_array;
|
my @query_params_array;
|
||||||
my $json = JSON->new;
|
my $json = JSON->new;
|
||||||
|
|
||||||
if ( ref( $args->{q} ) eq 'ARRAY' ) {
|
if ( ref($args) eq 'ARRAY' ) {
|
||||||
foreach my $q ( @{ $args->{q} } ) {
|
foreach my $q ( @{$args} ) {
|
||||||
push @query_params_array, $json->decode($q)
|
push @query_params_array, $json->decode($q)
|
||||||
if $q;
|
if $q;
|
||||||
}
|
}
|
||||||
|
@ -260,20 +220,19 @@ sub metric_types_report {
|
||||||
push @{$data}, $missing_result if $missing_result;
|
push @{$data}, $missing_result if $missing_result;
|
||||||
}
|
}
|
||||||
|
|
||||||
my @report_data;
|
my @metric_types = ('metric_types_report');
|
||||||
|
my $report_data = _get_report_data(
|
||||||
|
{
|
||||||
|
data_type => $data_type,
|
||||||
|
data => $data,
|
||||||
|
metric_types => \@metric_types,
|
||||||
|
access_types => undef,
|
||||||
|
usage_data_providers => $usage_data_providers,
|
||||||
|
period => 'monthly'
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
for my $data_object ( @{$data} ) {
|
return $c->render( status => 200, openapi => $report_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_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($_);
|
$c->unhandled_exception($_);
|
||||||
};
|
};
|
||||||
|
@ -291,21 +250,20 @@ sub provider_rollup_report {
|
||||||
|
|
||||||
return try {
|
return try {
|
||||||
|
|
||||||
my $args = $c->validation->output;
|
my $args = $c->param('q');
|
||||||
|
|
||||||
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 @query_params_array;
|
||||||
my $json = JSON->new;
|
my $json = JSON->new;
|
||||||
|
|
||||||
if ( ref( $args->{q} ) eq 'ARRAY' ) {
|
if ( ref($args) eq 'ARRAY' ) {
|
||||||
foreach my $q ( @{ $args->{q} } ) {
|
foreach my $q ( @{$args} ) {
|
||||||
push @query_params_array, $json->decode($q)
|
push @query_params_array, $json->decode($q)
|
||||||
if $q;
|
if $q;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
my $usage_data_providers_set = Koha::ERM::EUsage::UsageDataProviders->new;
|
||||||
|
my $usage_data_providers = $c->objects->search($usage_data_providers_set);
|
||||||
|
|
||||||
my $data_type = $c->validation->param('data_type');
|
my $data_type = $c->validation->param('data_type');
|
||||||
my $key = 'erm_usage_' . $data_type . 's';
|
my $key = 'erm_usage_' . $data_type . 's';
|
||||||
my $metric_types =
|
my $metric_types =
|
||||||
|
@ -325,9 +283,8 @@ sub provider_rollup_report {
|
||||||
grep { $metric_type eq $_->{metric_type} } @$statistics;
|
grep { $metric_type eq $_->{metric_type} } @$statistics;
|
||||||
my @usage_counts =
|
my @usage_counts =
|
||||||
map { $_->{usage_count} } @filtered_statistics;
|
map { $_->{usage_count} } @filtered_statistics;
|
||||||
my $sum =
|
my $sum = scalar(@usage_counts) > 0
|
||||||
scalar(@usage_counts) > 0
|
? _get_usage_total( \@usage_counts )
|
||||||
? eval join '+', @usage_counts
|
|
||||||
: 0;
|
: 0;
|
||||||
|
|
||||||
my $data_object_hash = _get_object_hash(
|
my $data_object_hash = _get_object_hash(
|
||||||
|
@ -349,7 +306,7 @@ sub provider_rollup_report {
|
||||||
map { $_->{usage_total} } @filtered_object_data;
|
map { $_->{usage_total} } @filtered_object_data;
|
||||||
my $provider_rollup_total =
|
my $provider_rollup_total =
|
||||||
scalar(@data_object_usage_totals) > 0
|
scalar(@data_object_usage_totals) > 0
|
||||||
? eval join '+', @data_object_usage_totals
|
? _get_usage_total(@data_object_usage_totals)
|
||||||
: 0;
|
: 0;
|
||||||
|
|
||||||
my %usage_data_provider_hash = (
|
my %usage_data_provider_hash = (
|
||||||
|
@ -481,6 +438,8 @@ sub _get_object_hash {
|
||||||
my $statistics = $args->{statistics};
|
my $statistics = $args->{statistics};
|
||||||
my $provider = $args->{provider};
|
my $provider = $args->{provider};
|
||||||
my $metric_type = $args->{metric_type};
|
my $metric_type = $args->{metric_type};
|
||||||
|
my $access_type = $args->{access_type};
|
||||||
|
my $yop = $args->{yop};
|
||||||
my $period = $args->{period};
|
my $period = $args->{period};
|
||||||
my $sum = $args->{sum};
|
my $sum = $args->{sum};
|
||||||
my %object_hash;
|
my %object_hash;
|
||||||
|
@ -497,7 +456,10 @@ sub _get_object_hash {
|
||||||
title_uri => $data_object->{title_uri},
|
title_uri => $data_object->{title_uri},
|
||||||
publisher => $data_object->{publisher},
|
publisher => $data_object->{publisher},
|
||||||
publisher_id => $data_object->{publisher_id},
|
publisher_id => $data_object->{publisher_id},
|
||||||
|
platform => $data_object->{platform},
|
||||||
metric_type => $metric_type,
|
metric_type => $metric_type,
|
||||||
|
access_type => $access_type,
|
||||||
|
yop => $yop,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if ( $data_type eq 'platform' ) {
|
if ( $data_type eq 'platform' ) {
|
||||||
|
@ -572,4 +534,169 @@ sub _get_missing_data {
|
||||||
return $item if $item;
|
return $item if $item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
=head3 _get_report_data
|
||||||
|
|
||||||
|
Takes the dataset retrieved from the database and converts it into a reportable set of data
|
||||||
|
Each title in the dataset needs to be split into rows depending on its different properties - YOP, access_type, metric_type
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub _get_report_data {
|
||||||
|
my ($args) = @_;
|
||||||
|
|
||||||
|
my $data = $args->{data};
|
||||||
|
my $metric_types = $args->{metric_types};
|
||||||
|
my $access_types = $args->{access_types};
|
||||||
|
my $usage_data_providers = $args->{usage_data_providers};
|
||||||
|
my $data_type = $args->{data_type};
|
||||||
|
my $period = $args->{period};
|
||||||
|
my $data_key = $period eq 'monthly' ? 'erm_usage_muses' : 'erm_usage_yuses';
|
||||||
|
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_name = $provider_object[0]->{name};
|
||||||
|
|
||||||
|
my $statistics = $data_object->{$data_key};
|
||||||
|
my @yops = uniq map( $_->{yop}, @$statistics );
|
||||||
|
@yops = grep defined, @yops;
|
||||||
|
|
||||||
|
# Split data objects into metric_types i.e. one table row per metric_type
|
||||||
|
if ( scalar(@yops) > 0 ) {
|
||||||
|
for my $yop (@yops) {
|
||||||
|
_create_report_rows(
|
||||||
|
{
|
||||||
|
data_object => $data_object,
|
||||||
|
statistics => $statistics,
|
||||||
|
metric_types => $metric_types,
|
||||||
|
access_types => $access_types,
|
||||||
|
provider_name => $provider_name,
|
||||||
|
data_type => $data_type,
|
||||||
|
period => $period,
|
||||||
|
report_data => \@report_data,
|
||||||
|
yop => $yop,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
_create_report_rows(
|
||||||
|
{
|
||||||
|
data_object => $data_object,
|
||||||
|
statistics => $statistics,
|
||||||
|
metric_types => $metric_types,
|
||||||
|
access_types => $access_types,
|
||||||
|
provider_name => $provider_name,
|
||||||
|
data_type => $data_type,
|
||||||
|
period => $period,
|
||||||
|
report_data => \@report_data,
|
||||||
|
yop => undef,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return \@report_data;
|
||||||
|
}
|
||||||
|
|
||||||
|
=head3 _create_report_rows
|
||||||
|
|
||||||
|
A helper function for creating report rows based on access_type and metric_type
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub _create_report_rows {
|
||||||
|
my ($args) = @_;
|
||||||
|
|
||||||
|
my $data_object = $args->{data_object};
|
||||||
|
my $statistics = $args->{statistics};
|
||||||
|
my $metric_types = $args->{metric_types};
|
||||||
|
my $access_types = $args->{access_types};
|
||||||
|
my $provider_name = $args->{provider_name};
|
||||||
|
my $data_type = $args->{data_type};
|
||||||
|
my $period = $args->{period};
|
||||||
|
my $report_data = $args->{report_data};
|
||||||
|
my $yop = $args->{yop};
|
||||||
|
|
||||||
|
if ( $access_types && scalar(@$access_types) > 0 ) {
|
||||||
|
for my $access_type (@$access_types) {
|
||||||
|
for my $metric_type (@$metric_types) {
|
||||||
|
my @usage_stats = $yop ? grep { $yop eq $_->{yop} } @$statistics : @$statistics;
|
||||||
|
my @stats_by_access_type =
|
||||||
|
grep { $access_type eq $_->{access_type} } @usage_stats;
|
||||||
|
my @stats_by_metric_type =
|
||||||
|
grep { $metric_type eq $_->{metric_type} } @stats_by_access_type;
|
||||||
|
my @usage_counts =
|
||||||
|
map { $_->{usage_count} } @stats_by_metric_type;
|
||||||
|
my $sum = $period eq 'monthly' && scalar(@usage_counts) > 0
|
||||||
|
? _get_usage_total( \@usage_counts )
|
||||||
|
: 0;
|
||||||
|
|
||||||
|
my $data_object_hash = _get_object_hash(
|
||||||
|
{
|
||||||
|
data_type => $data_type,
|
||||||
|
data_object => $data_object,
|
||||||
|
statistics => \@stats_by_metric_type,
|
||||||
|
provider => $provider_name,
|
||||||
|
metric_type => $metric_type,
|
||||||
|
access_type => $access_type,
|
||||||
|
yop => $yop ? $yop : undef,
|
||||||
|
period => $period,
|
||||||
|
sum => $sum
|
||||||
|
}
|
||||||
|
);
|
||||||
|
push @$report_data, $data_object_hash;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for my $metric_type (@$metric_types) {
|
||||||
|
my @usage_stats = $yop ? grep { $yop eq $_->{yop} } @$statistics : @$statistics;
|
||||||
|
my @stats_by_metric_type =
|
||||||
|
$metric_type ne 'metric_types_report'
|
||||||
|
? grep { $metric_type eq $_->{metric_type} } @usage_stats
|
||||||
|
: @usage_stats;
|
||||||
|
my @usage_counts =
|
||||||
|
map { $_->{usage_count} } @stats_by_metric_type;
|
||||||
|
my $sum = $period eq 'monthly' && scalar(@usage_counts) > 0
|
||||||
|
? _get_usage_total(\@usage_counts)
|
||||||
|
: 0;
|
||||||
|
|
||||||
|
my $data_object_hash = _get_object_hash(
|
||||||
|
{
|
||||||
|
data_type => $data_type,
|
||||||
|
data_object => $data_object,
|
||||||
|
statistics => \@stats_by_metric_type,
|
||||||
|
provider => $provider_name,
|
||||||
|
metric_type => $metric_type,
|
||||||
|
access_type => undef,
|
||||||
|
yop => $yop ? $yop : undef,
|
||||||
|
period => $period,
|
||||||
|
sum => $sum
|
||||||
|
}
|
||||||
|
);
|
||||||
|
push @$report_data, $data_object_hash;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
=head3
|
||||||
|
|
||||||
|
A method for summing the usage counts for a data object
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub _get_usage_total {
|
||||||
|
my ( $statistics ) = @_;
|
||||||
|
|
||||||
|
my $sum = 0;
|
||||||
|
foreach my $statistic (@$statistics) {
|
||||||
|
$sum += $statistic;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $sum
|
||||||
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
|
@ -39,11 +39,11 @@ use Koha::Exceptions;
|
||||||
sub get {
|
sub get {
|
||||||
my $c = shift->openapi->valid_input or return;
|
my $c = shift->openapi->valid_input or return;
|
||||||
|
|
||||||
my $args = $c->validation->output;
|
my $args = $c->param('q');
|
||||||
my $json = JSON->new;
|
my $json = JSON->new;
|
||||||
|
|
||||||
my @query_params_array =
|
my @query_params_array =
|
||||||
map { $_ ? $json->decode($_) : () } @{ $args->{q} };
|
map { $_ ? $json->decode($_) : () } @{ $args };
|
||||||
|
|
||||||
my $service_url = $query_params_array[0]->{url};
|
my $service_url = $query_params_array[0]->{url};
|
||||||
|
|
||||||
|
|
|
@ -125,13 +125,12 @@ export default {
|
||||||
const table = this.$refs.table.$el.getElementsByTagName("table")[0]
|
const table = this.$refs.table.$el.getElementsByTagName("table")[0]
|
||||||
|
|
||||||
const row = table.insertRow(0)
|
const row = table.insertRow(0)
|
||||||
const [cellOne, cellTwo, cellThree, cellFour, cellFive] = [
|
const [cellOne, cellTwo, cellThree, cellFour, cellFive] =
|
||||||
...Array(5).keys(),
|
Array.from("1".repeat(5)).map(item => {
|
||||||
].map(item => {
|
const cell = document.createElement("th")
|
||||||
const cell = document.createElement("th")
|
row.appendChild(cell)
|
||||||
row.appendChild(cell)
|
return cell
|
||||||
return cell
|
})
|
||||||
})
|
|
||||||
cellTwo.colSpan = 2
|
cellTwo.colSpan = 2
|
||||||
cellTwo.innerHTML = "Title reports"
|
cellTwo.innerHTML = "Title reports"
|
||||||
cellThree.colSpan = 2
|
cellThree.colSpan = 2
|
||||||
|
|
|
@ -98,10 +98,10 @@
|
||||||
>{{ $__("Choose metric type") }}:</label
|
>{{ $__("Choose metric type") }}:</label
|
||||||
>
|
>
|
||||||
<v-select
|
<v-select
|
||||||
id="metric_type"
|
id="metric_types"
|
||||||
v-model="query.metric_types"
|
v-model="query.metric_types"
|
||||||
label="description"
|
label="description"
|
||||||
:reduce="report => report.value"
|
:reduce="metric => metric.value"
|
||||||
:options="metric_types_options"
|
:options="metric_types_options"
|
||||||
multiple
|
multiple
|
||||||
:disabled="
|
:disabled="
|
||||||
|
@ -109,6 +109,21 @@
|
||||||
"
|
"
|
||||||
/>
|
/>
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<label for="access_types"
|
||||||
|
>{{ $__("Choose access type") }}:</label
|
||||||
|
>
|
||||||
|
<v-select
|
||||||
|
id="access_types"
|
||||||
|
v-model="query.access_types"
|
||||||
|
label="description"
|
||||||
|
:options="access_types_options"
|
||||||
|
multiple
|
||||||
|
:disabled="
|
||||||
|
this.access_types_options.length === 0
|
||||||
|
"
|
||||||
|
/>
|
||||||
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<label for="start_year"
|
<label for="start_year"
|
||||||
>{{ $__("Start year") }}:</label
|
>{{ $__("Start year") }}:</label
|
||||||
|
@ -379,6 +394,7 @@ export default {
|
||||||
data_display: "monthly",
|
data_display: "monthly",
|
||||||
report_type: null,
|
report_type: null,
|
||||||
metric_types: null,
|
metric_types: null,
|
||||||
|
access_types: null,
|
||||||
usage_data_providers: null,
|
usage_data_providers: null,
|
||||||
keywords: null,
|
keywords: null,
|
||||||
start_month: null,
|
start_month: null,
|
||||||
|
@ -449,6 +465,7 @@ export default {
|
||||||
No_License: ["DR", "DR_D2", "TR", "TR_B2", "TR_J2", "IR"],
|
No_License: ["DR", "DR_D2", "TR", "TR_B2", "TR_J2", "IR"],
|
||||||
},
|
},
|
||||||
metric_types_options: [],
|
metric_types_options: [],
|
||||||
|
access_types_options: [],
|
||||||
report_types_options: [...this.av_report_types],
|
report_types_options: [...this.av_report_types],
|
||||||
filter_data: [],
|
filter_data: [],
|
||||||
usage_data_provider_list: [...this.usage_data_providers],
|
usage_data_provider_list: [...this.usage_data_providers],
|
||||||
|
@ -508,6 +525,7 @@ export default {
|
||||||
data_display: "monthly",
|
data_display: "monthly",
|
||||||
report_type: null,
|
report_type: null,
|
||||||
metric_types: null,
|
metric_types: null,
|
||||||
|
access_types: null,
|
||||||
usage_data_providers: null,
|
usage_data_providers: null,
|
||||||
keywords: null,
|
keywords: null,
|
||||||
start_month: null,
|
start_month: null,
|
||||||
|
@ -650,6 +668,7 @@ export default {
|
||||||
start_year,
|
start_year,
|
||||||
end_year,
|
end_year,
|
||||||
metric_types,
|
metric_types,
|
||||||
|
access_types,
|
||||||
usage_data_providers,
|
usage_data_providers,
|
||||||
keywords,
|
keywords,
|
||||||
report_type,
|
report_type,
|
||||||
|
@ -689,6 +708,10 @@ export default {
|
||||||
if (metric_types) {
|
if (metric_types) {
|
||||||
queryByYear[`${prefix}.metric_type`] = metric_types
|
queryByYear[`${prefix}.metric_type`] = metric_types
|
||||||
}
|
}
|
||||||
|
// Add any access types query
|
||||||
|
if (access_types) {
|
||||||
|
queryByYear[`${prefix}.access_type`] = access_types
|
||||||
|
}
|
||||||
// Add any data provider query
|
// Add any data provider query
|
||||||
if (usage_data_providers) {
|
if (usage_data_providers) {
|
||||||
queryByYear[`${prefix}.usage_data_provider_id`] =
|
queryByYear[`${prefix}.usage_data_provider_id`] =
|
||||||
|
@ -708,6 +731,7 @@ export default {
|
||||||
start_year,
|
start_year,
|
||||||
end_year,
|
end_year,
|
||||||
metric_types,
|
metric_types,
|
||||||
|
access_types,
|
||||||
usage_data_providers,
|
usage_data_providers,
|
||||||
keywords,
|
keywords,
|
||||||
report_type,
|
report_type,
|
||||||
|
@ -727,13 +751,16 @@ export default {
|
||||||
if (metric_types) {
|
if (metric_types) {
|
||||||
queryObject[`erm_usage_yuses.metric_type`] = metric_types
|
queryObject[`erm_usage_yuses.metric_type`] = metric_types
|
||||||
}
|
}
|
||||||
// Add any title query
|
// Add any access types query
|
||||||
|
if (access_types) {
|
||||||
|
queryObject[`erm_usage_yuses.access_type`] = access_types
|
||||||
|
}
|
||||||
// Add any keyword query
|
// Add any keyword query
|
||||||
if (keywords) {
|
if (keywords) {
|
||||||
const object_ids = keywords.map(object => {
|
const object_ids = keywords.map(object => {
|
||||||
return object[`${db_table}_id`]
|
return object[`${db_table}_id`]
|
||||||
})
|
})
|
||||||
queryByYear[`erm_usage_yuses.${db_table}_id`] = object_ids
|
queryObject[`erm_usage_yuses.${db_table}_id`] = object_ids
|
||||||
}
|
}
|
||||||
// Add any data provider query
|
// Add any data provider query
|
||||||
if (usage_data_providers) {
|
if (usage_data_providers) {
|
||||||
|
@ -772,6 +799,12 @@ export default {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (report_type === "TR_J3" || report_type === "TR_B3") {
|
||||||
|
this.access_types_options = ["Controlled", "OA_Gold"]
|
||||||
|
} else {
|
||||||
|
this.access_types_options = []
|
||||||
|
}
|
||||||
|
|
||||||
for (const metric in this.metric_types_matrix) {
|
for (const metric in this.metric_types_matrix) {
|
||||||
if (
|
if (
|
||||||
this.metric_types_matrix[metric].includes(
|
this.metric_types_matrix[metric].includes(
|
||||||
|
@ -889,6 +922,7 @@ export default {
|
||||||
data_display,
|
data_display,
|
||||||
report_type,
|
report_type,
|
||||||
metric_types,
|
metric_types,
|
||||||
|
access_types,
|
||||||
} = queryObject
|
} = queryObject
|
||||||
|
|
||||||
if (!report_type || !start_year || !end_year) {
|
if (!report_type || !start_year || !end_year) {
|
||||||
|
@ -918,6 +952,18 @@ export default {
|
||||||
)
|
)
|
||||||
queryObject.metric_types = final_metric_types
|
queryObject.metric_types = final_metric_types
|
||||||
}
|
}
|
||||||
|
// If no access types are selected then all possible values should be included for backend data filtering ( but only for TR_J3 and TR_B3 reports)
|
||||||
|
if (
|
||||||
|
(report_type === "TR_J3" || report_type === "TR_B3") &&
|
||||||
|
(!access_types || (access_types && access_types.length === 0))
|
||||||
|
) {
|
||||||
|
const final_access_types = this.access_types_options.map(
|
||||||
|
access => {
|
||||||
|
return access
|
||||||
|
}
|
||||||
|
)
|
||||||
|
queryObject.access_types = final_access_types
|
||||||
|
}
|
||||||
|
|
||||||
// Determine which database table should be queried
|
// Determine which database table should be queried
|
||||||
const url = !data_display.includes("yearly")
|
const url = !data_display.includes("yearly")
|
||||||
|
|
|
@ -31,11 +31,13 @@ export default {
|
||||||
setup() {
|
setup() {
|
||||||
const table = ref()
|
const table = ref()
|
||||||
|
|
||||||
const { getMonthsData, getColumnOptions } = inject("reportsStore")
|
const { getMonthsData, getColumnOptions, checkReportColumns } =
|
||||||
|
inject("reportsStore")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
getMonthsData,
|
getMonthsData,
|
||||||
getColumnOptions,
|
getColumnOptions,
|
||||||
|
checkReportColumns,
|
||||||
table,
|
table,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -106,13 +108,14 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
buildColumnArray(report_type, params, data_type) {
|
buildColumnArray(report_display, params, data_type) {
|
||||||
const columns = params.columns
|
const columns = params.columns
|
||||||
const months_data = this.getMonthsData()
|
const months_data = this.getMonthsData()
|
||||||
const column_options = this.getColumnOptions()
|
const column_options = this.getColumnOptions()
|
||||||
const time_period_columns = params.tp_columns
|
const time_period_columns = params.tp_columns
|
||||||
const yearly_filter = params.yearly_filter
|
const yearly_filter = params.yearly_filter
|
||||||
const query = params.queryObject
|
const query = params.queryObject
|
||||||
|
const report_type = params.queryObject.report_type
|
||||||
const column_set = []
|
const column_set = []
|
||||||
|
|
||||||
columns.forEach(column => {
|
columns.forEach(column => {
|
||||||
|
@ -121,7 +124,7 @@ export default {
|
||||||
if (column !== 1) column_options[column].active = false
|
if (column !== 1) column_options[column].active = false
|
||||||
})
|
})
|
||||||
|
|
||||||
report_type !== "usage_data_provider" &&
|
report_display !== "usage_data_provider" &&
|
||||||
column_set.unshift({
|
column_set.unshift({
|
||||||
title: __(
|
title: __(
|
||||||
data_type.charAt(0).toUpperCase() + data_type.slice(1)
|
data_type.charAt(0).toUpperCase() + data_type.slice(1)
|
||||||
|
@ -132,7 +135,25 @@ export default {
|
||||||
})
|
})
|
||||||
|
|
||||||
// Add metric type to each row
|
// Add metric type to each row
|
||||||
if (report_type !== "metric_type") {
|
if (report_display !== "metric_type") {
|
||||||
|
// Add yop if it is required
|
||||||
|
if (this.checkReportColumns(report_type, "YOP")) {
|
||||||
|
column_set.push({
|
||||||
|
title: __("YOP"),
|
||||||
|
data: "yop",
|
||||||
|
searchable: true,
|
||||||
|
orderable: true,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// Add access type if it is required
|
||||||
|
if (this.checkReportColumns(report_type, "Access_Type")) {
|
||||||
|
column_set.push({
|
||||||
|
title: __("Access type"),
|
||||||
|
data: "access_type",
|
||||||
|
searchable: true,
|
||||||
|
orderable: true,
|
||||||
|
})
|
||||||
|
}
|
||||||
column_set.push({
|
column_set.push({
|
||||||
title: __("Metric"),
|
title: __("Metric"),
|
||||||
render: function (data, type, row, meta) {
|
render: function (data, type, row, meta) {
|
||||||
|
@ -143,7 +164,7 @@ export default {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (report_type === "usage_data_provider") {
|
if (report_display === "usage_data_provider") {
|
||||||
column_set.unshift({
|
column_set.unshift({
|
||||||
title: __("Data provider"),
|
title: __("Data provider"),
|
||||||
data: "name",
|
data: "name",
|
||||||
|
@ -180,7 +201,7 @@ export default {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
if (report_type.includes("monthly")) {
|
if (report_display.includes("monthly")) {
|
||||||
const years = Object.keys(time_period_columns)
|
const years = Object.keys(time_period_columns)
|
||||||
|
|
||||||
years.forEach(year => {
|
years.forEach(year => {
|
||||||
|
@ -218,7 +239,7 @@ export default {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if (report_type === "yearly") {
|
if (report_display === "yearly") {
|
||||||
const years = time_period_columns
|
const years = time_period_columns
|
||||||
|
|
||||||
years.forEach(year => {
|
years.forEach(year => {
|
||||||
|
@ -239,32 +260,74 @@ export default {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if (report_type === "metric_type") {
|
if (report_display === "metric_type") {
|
||||||
const metric_types = query.metric_types
|
const metric_types = query.metric_types
|
||||||
metric_types.forEach(metric => {
|
const access_types = query.access_types
|
||||||
|
// Add yop if it is required
|
||||||
|
if (this.checkReportColumns(report_type, "YOP")) {
|
||||||
column_set.push({
|
column_set.push({
|
||||||
title: __(metric),
|
title: __("YOP"),
|
||||||
render: function (data, type, row, meta) {
|
data: "yop",
|
||||||
const filterByMetric =
|
|
||||||
row.erm_usage_muses.filter(
|
|
||||||
item => item.metric_type === metric
|
|
||||||
)
|
|
||||||
const period_total = filterByMetric.reduce(
|
|
||||||
(acc, item) => {
|
|
||||||
return acc + item.usage_count
|
|
||||||
},
|
|
||||||
0
|
|
||||||
)
|
|
||||||
return period_total
|
|
||||||
},
|
|
||||||
searchable: true,
|
searchable: true,
|
||||||
orderable: true,
|
orderable: true,
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
metric_types.forEach(metric => {
|
||||||
|
if (access_types && access_types.length > 0) {
|
||||||
|
access_types.forEach(access => {
|
||||||
|
column_set.push({
|
||||||
|
title: __(access),
|
||||||
|
render: function (data, type, row, meta) {
|
||||||
|
const filterByType =
|
||||||
|
row.erm_usage_muses.filter(
|
||||||
|
item =>
|
||||||
|
item.access_type === access
|
||||||
|
)
|
||||||
|
const filterByMetric =
|
||||||
|
filterByType.filter(
|
||||||
|
item =>
|
||||||
|
item.metric_type === metric
|
||||||
|
)
|
||||||
|
const period_total =
|
||||||
|
filterByMetric.reduce(
|
||||||
|
(acc, item) => {
|
||||||
|
return (
|
||||||
|
acc + item.usage_count
|
||||||
|
)
|
||||||
|
},
|
||||||
|
0
|
||||||
|
)
|
||||||
|
return period_total
|
||||||
|
},
|
||||||
|
searchable: false,
|
||||||
|
orderable: false,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
column_set.push({
|
||||||
|
title: __(metric),
|
||||||
|
render: function (data, type, row, meta) {
|
||||||
|
const filterByMetric =
|
||||||
|
row.erm_usage_muses.filter(
|
||||||
|
item => item.metric_type === metric
|
||||||
|
)
|
||||||
|
const period_total = filterByMetric.reduce(
|
||||||
|
(acc, item) => {
|
||||||
|
return acc + item.usage_count
|
||||||
|
},
|
||||||
|
0
|
||||||
|
)
|
||||||
|
return period_total
|
||||||
|
},
|
||||||
|
searchable: false,
|
||||||
|
orderable: false,
|
||||||
|
})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Add totals column if required
|
// Add totals column if required
|
||||||
if (report_type === "monthly_with_totals") {
|
if (report_display === "monthly_with_totals") {
|
||||||
column_set.push({
|
column_set.push({
|
||||||
title: __("Period total"),
|
title: __("Period total"),
|
||||||
data: "usage_total",
|
data: "usage_total",
|
||||||
|
@ -281,6 +344,7 @@ export default {
|
||||||
const queryObject = {}
|
const queryObject = {}
|
||||||
const {
|
const {
|
||||||
metric_types,
|
metric_types,
|
||||||
|
access_types,
|
||||||
usage_data_providers,
|
usage_data_providers,
|
||||||
keywords,
|
keywords,
|
||||||
report_type,
|
report_type,
|
||||||
|
@ -321,6 +385,10 @@ export default {
|
||||||
if (metric_types) {
|
if (metric_types) {
|
||||||
queryObject[`erm_usage_muses.metric_type`] = metric_types
|
queryObject[`erm_usage_muses.metric_type`] = metric_types
|
||||||
}
|
}
|
||||||
|
// Add any metric types query
|
||||||
|
if (access_types) {
|
||||||
|
queryObject[`erm_usage_muses.access_type`] = access_types
|
||||||
|
}
|
||||||
// Add any data provider query
|
// Add any data provider query
|
||||||
if (usage_data_providers) {
|
if (usage_data_providers) {
|
||||||
queryObject[`erm_usage_muses.usage_data_provider_id`] =
|
queryObject[`erm_usage_muses.usage_data_provider_id`] =
|
||||||
|
@ -350,14 +418,16 @@ export default {
|
||||||
return url
|
return url
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mergeTitleDataIntoOneLine(numberOfMetricTypes) {
|
mergeTitleDataIntoOneLine(numberOfMetricTypes, numberOfAccessTypes) {
|
||||||
let dt = this.$refs.table.useTableObject()
|
let dt = this.$refs.table.useTableObject()
|
||||||
dt.on("draw", () => {
|
dt.on("draw", () => {
|
||||||
const rows = dt.rows().nodes().to$()
|
const rows = dt.rows().nodes().to$()
|
||||||
|
const numberOfRows = numberOfAccessTypes
|
||||||
|
? numberOfMetricTypes * numberOfAccessTypes
|
||||||
|
: numberOfMetricTypes
|
||||||
const data_rows = []
|
const data_rows = []
|
||||||
for (let i = 0; i < rows.length; i = i + numberOfMetricTypes) {
|
for (let i = 0; i < rows.length; i = i + numberOfRows) {
|
||||||
data_rows.push([rows.slice(i, i + numberOfMetricTypes)])
|
data_rows.push([rows.slice(i, i + numberOfRows)])
|
||||||
}
|
}
|
||||||
|
|
||||||
data_rows
|
data_rows
|
||||||
|
@ -366,7 +436,7 @@ export default {
|
||||||
Array.from(titleRows).forEach((row, i) => {
|
Array.from(titleRows).forEach((row, i) => {
|
||||||
const cells = row.cells
|
const cells = row.cells
|
||||||
if (i === 0) {
|
if (i === 0) {
|
||||||
cells[0].rowSpan = numberOfMetricTypes
|
cells[0].rowSpan = numberOfRows
|
||||||
cells[0].style.textAlign = "center"
|
cells[0].style.textAlign = "center"
|
||||||
cells[0].style.verticalAlign = "middle"
|
cells[0].style.verticalAlign = "middle"
|
||||||
cells[0].style.borderRight = "1px solid #BCBCBC"
|
cells[0].style.borderRight = "1px solid #BCBCBC"
|
||||||
|
@ -378,15 +448,50 @@ export default {
|
||||||
})
|
})
|
||||||
this.$refs.table_div.classList.remove("hide-table")
|
this.$refs.table_div.classList.remove("hide-table")
|
||||||
},
|
},
|
||||||
|
createMetricReportTableHeader(metric_types, access_types) {
|
||||||
|
const table = this.$refs.table.$el.getElementsByTagName("table")[0]
|
||||||
|
const numberOfColumns = table.rows[0].cells.length
|
||||||
|
const dataColumns = metric_types.length * access_types
|
||||||
|
const numberOfNonStatisticColumns = numberOfColumns - dataColumns
|
||||||
|
const numberOfCellsToCreate =
|
||||||
|
numberOfNonStatisticColumns + metric_types.length
|
||||||
|
|
||||||
|
const row = table.insertRow(0)
|
||||||
|
const cellsToInsert = Array.from("1".repeat(numberOfCellsToCreate))
|
||||||
|
const cells = cellsToInsert.map(item => {
|
||||||
|
const cell = document.createElement("th")
|
||||||
|
row.appendChild(cell)
|
||||||
|
return cell
|
||||||
|
})
|
||||||
|
|
||||||
|
const metricTypeColumns = cells.splice(numberOfNonStatisticColumns)
|
||||||
|
metric_types.forEach((metric, i) => {
|
||||||
|
const cell = metricTypeColumns[i]
|
||||||
|
cell.colSpan = access_types
|
||||||
|
cell.innerHTML = metric
|
||||||
|
})
|
||||||
|
this.$refs.table_div.classList.remove("hide-table")
|
||||||
|
},
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
table() {
|
table() {
|
||||||
if (this.report_type !== "metric_type") {
|
const number_of_access_types = this.params.queryObject.access_types
|
||||||
this.mergeTitleDataIntoOneLine(
|
? this.params.queryObject.access_types.length
|
||||||
this.params.queryObject.metric_types.length
|
: 0
|
||||||
)
|
if (this.report_type === "metric_type") {
|
||||||
|
if (number_of_access_types) {
|
||||||
|
this.createMetricReportTableHeader(
|
||||||
|
this.params.queryObject.metric_types,
|
||||||
|
number_of_access_types
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
this.$refs.table_div.classList.remove("hide-table")
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.$refs.table_div.classList.remove("hide-table")
|
this.mergeTitleDataIntoOneLine(
|
||||||
|
this.params.queryObject.metric_types.length,
|
||||||
|
number_of_access_types
|
||||||
|
)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { defineStore } from "pinia";
|
import { defineStore } from "pinia";
|
||||||
|
|
||||||
export const useReportsStore = defineStore('reports', {
|
export const useReportsStore = defineStore("reports", {
|
||||||
state: () => ({
|
state: () => ({
|
||||||
months_data: [
|
months_data: [
|
||||||
{ short: "Jan", description: "January", value: 1, active: true },
|
{ short: "Jan", description: "January", value: 1, active: true },
|
||||||
|
@ -22,7 +22,7 @@ export const useReportsStore = defineStore('reports', {
|
||||||
id: 1,
|
id: 1,
|
||||||
name: "Provider name",
|
name: "Provider name",
|
||||||
active: true,
|
active: true,
|
||||||
used_by: ["title", "item", "database", 'platform'],
|
used_by: ["title", "item", "database", "platform"],
|
||||||
column: {
|
column: {
|
||||||
title: __("Data provider"),
|
title: __("Data provider"),
|
||||||
data: "provider_name",
|
data: "provider_name",
|
||||||
|
@ -115,13 +115,24 @@ export const useReportsStore = defineStore('reports', {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
report_type_map: {
|
||||||
|
TR_B1: ["YOP", "ISBN"],
|
||||||
|
TR_B2: ["YOP", "ISBN"],
|
||||||
|
TR_B3: ["YOP", "Access_Type", "ISBN"],
|
||||||
|
TR_J3: ["Access_Type"],
|
||||||
|
TR_J4: ["YOP"],
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
actions: {
|
actions: {
|
||||||
getMonthsData() {
|
getMonthsData() {
|
||||||
return this.months_data
|
return this.months_data;
|
||||||
},
|
},
|
||||||
getColumnOptions() {
|
getColumnOptions() {
|
||||||
return this.title_property_column_options
|
return this.title_property_column_options;
|
||||||
}
|
},
|
||||||
}
|
checkReportColumns(report_type, column) {
|
||||||
})
|
if (!this.report_type_map.hasOwnProperty(report_type)) return false;
|
||||||
|
return this.report_type_map[report_type].includes(column);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
Loading…
Reference in a new issue