Bug 34587: (QA follow-up) Tidy

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Nick Clemens 2023-10-27 15:36:06 +00:00 committed by Tomas Cohen Arazi
parent a35403cb84
commit 17cf580f19
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F
15 changed files with 184 additions and 171 deletions

View file

@ -488,31 +488,31 @@ sub _is_same_usage_object {
return unless $previous_object;
if ( $previous_object->print_issn && $row->{Print_ISSN} ){
if ( $previous_object->print_issn && $row->{Print_ISSN} ) {
return unless $previous_object->print_issn eq $row->{Print_ISSN};
}
if ( $previous_object->online_issn && $row->{Online_ISSN} ){
if ( $previous_object->online_issn && $row->{Online_ISSN} ) {
return unless $previous_object->online_issn eq $row->{Online_ISSN};
}
if ( $previous_object->proprietary_id && $row->{Proprietary_ID} ){
if ( $previous_object->proprietary_id && $row->{Proprietary_ID} ) {
return unless $previous_object->proprietary_id eq $row->{Proprietary_ID};
}
if ( $previous_object->publisher && $row->{Publisher} ){
if ( $previous_object->publisher && $row->{Publisher} ) {
return unless $previous_object->publisher eq $row->{Publisher};
}
if ( $previous_object->platform && $row->{Platform} ){
if ( $previous_object->platform && $row->{Platform} ) {
return unless $previous_object->platform eq $row->{Platform};
}
if ( $previous_object->title_doi && $row->{DOI} ){
if ( $previous_object->title_doi && $row->{DOI} ) {
return unless $previous_object->title_doi eq $row->{DOI};
}
if ( $previous_object->title && $row->{Title} ){
if ( $previous_object->title && $row->{Title} ) {
return unless $previous_object->title eq $row->{Title};
}

View file

@ -110,10 +110,10 @@ sub _COUNTER_report_header {
my $end_date = $self->_get_SUSHI_Name_Value( $header->{Report_Filters}, "End_Date" );
return (
[ Report_Name => $header->{Report_Name} || "" ],
[ Report_ID => $header->{Report_ID} || "" ],
[ Release => $header->{Release} || "" ],
[ Institution_Name => $header->{Institution_Name} || "" ],
[ Report_Name => $header->{Report_Name} || "" ],
[ Report_ID => $header->{Report_ID} || "" ],
[ Release => $header->{Release} || "" ],
[ Institution_Name => $header->{Institution_Name} || "" ],
[ Institution_ID => join( "; ", map( $_->{Type} . ":" . $_->{Value}, @{ $header->{Institution_ID} } ) ) || "" ],
[ Metric_Types => join( "; ", split( /\|/, $metric_types_string[0] ) ) || "" ],
[ Report_Filters => join( "; ", map( $_->{Name} . ":" . $_->{Value}, @{ $header->{Report_Filters} } ) ) || "" ],
@ -127,7 +127,7 @@ sub _COUNTER_report_header {
|| ""
],
[ Reporting_Period => "Begin_Date=" . $begin_date . "; End_Date=" . $end_date ],
[ Created => $header->{Created} || "" ],
[ Created => $header->{Created} || "" ],
[ Created_By => $header->{Created_By} || "" ],
[""] #empty 13th line (COUNTER 5)
);
@ -269,7 +269,7 @@ sub _COUNTER_platform_report_row {
return (
[
$platform_row->{Platform} || "", $metric_type,
$total_usage, @{$monthly_usages}
$total_usage, @{$monthly_usages}
]
);
}
@ -715,7 +715,7 @@ sub get_report_type_specific_fields {
"TR_J3" => ['Access_Type'],
"TR_J4" => ['YOP'],
"IR_A1" => [
'Authors', 'Publication_Date', 'Article_Version', 'Print_ISSN', 'Online_ISSN', 'Parent_Title',
'Authors', 'Publication_Date', 'Article_Version', 'Print_ISSN', 'Online_ISSN', 'Parent_Title',
'Parent_Authors', 'Parent_Article_Version', 'Parent_DOI', 'Parent_Proprietary_ID', 'Parent_Print_ISSN',
'Parent_Online_ISSN', 'Parent_URI', 'Access_Type'
],

View file

@ -275,7 +275,7 @@ sub test_connection {
$url .= 'status';
$url .= '?customer_id=' . $self->customer_id;
$url .= '&requestor_id=' . $self->requestor_id if $self->requestor_id;
$url .= '&api_key=' . $self->api_key if $self->api_key;
$url .= '&api_key=' . $self->api_key if $self->api_key;
my $request = HTTP::Request->new( 'GET' => $url );
my $ua = LWP::UserAgent->new;
@ -342,7 +342,7 @@ Method to embed erm_usage_platforms to platforms for report formatting
=cut
sub erm_usage_platforms {
my ( $self ) = @_;
my ($self) = @_;
my $usage_platform_rs = $self->_result->erm_usage_platforms;
return Koha::ERM::EUsage::UsagePlatforms->_new_from_dbic($usage_platform_rs);
}
@ -354,7 +354,7 @@ Method to embed erm_usage_items to items for report formatting
=cut
sub erm_usage_items {
my ( $self ) = @_;
my ($self) = @_;
my $usage_item_rs = $self->_result->erm_usage_items;
return Koha::ERM::EUsage::UsageItems->_new_from_dbic($usage_item_rs);
}
@ -366,7 +366,7 @@ Method to embed erm_usage_databases to databases for report formatting
=cut
sub erm_usage_databases {
my ( $self ) = @_;
my ($self) = @_;
my $usage_database_rs = $self->_result->erm_usage_databases;
return Koha::ERM::EUsage::UsageDatabases->_new_from_dbic($usage_database_rs);
}
@ -393,9 +393,9 @@ sub _build_url_query {
$url .= lc $self->{report_type};
$url .= '?customer_id=' . $self->customer_id;
$url .= '&requestor_id=' . $self->requestor_id if $self->requestor_id;
$url .= '&api_key=' . $self->api_key if $self->api_key;
$url .= '&api_key=' . $self->api_key if $self->api_key;
$url .= '&begin_date=' . substr $self->{begin_date}, 0, 7 if $self->{begin_date};
$url .= '&end_date=' . substr $self->{end_date}, 0, 7 if $self->{end_date};
$url .= '&end_date=' . substr $self->{end_date}, 0, 7 if $self->{end_date};
return $url;
}

View file

@ -24,7 +24,7 @@ use Mojo::Base 'Mojolicious::Controller';
use Koha::ERM::EUsage::CounterFiles;
use Scalar::Util qw( blessed );
use Try::Tiny qw( catch try );
use Try::Tiny qw( catch try );
=head1 API

View file

@ -24,7 +24,7 @@ use Mojo::Base 'Mojolicious::Controller';
use Koha::ERM::EUsage::CounterLogs;
use Scalar::Util qw( blessed );
use Try::Tiny qw( catch try );
use Try::Tiny qw( catch try );
=head1 API

View file

@ -23,8 +23,8 @@ use Mojo::Base 'Mojolicious::Controller';
use HTTP::Request;
use LWP::UserAgent;
use Scalar::Util qw( blessed );
use JSON qw( from_json decode_json encode_json );
use Try::Tiny qw( catch try );
use JSON qw( from_json decode_json encode_json );
use Try::Tiny qw( catch try );
use Koha::Exceptions;

View file

@ -1,4 +1,5 @@
[% USE Koha %]
[% USE raw %]
[% BLOCK report %]
[% SET report = job.report %]

View file

@ -24,7 +24,7 @@ import { useVendorStore } from "../stores/vendors";
import { useAVStore } from "../stores/authorised-values";
import { useERMStore } from "../stores/erm";
import { useNavigationStore } from "../stores/navigation";
import { useReportsStore } from "../stores/usage-reports"
import { useReportsStore } from "../stores/usage-reports";
import i18n from "../i18n";
const pinia = createPinia();
@ -56,8 +56,8 @@ app.provide("AVStore", AVStore);
app.provide("navigationStore", navigationStore);
const ERMStore = useERMStore(pinia);
app.provide("ERMStore", ERMStore);
const reportsStore = useReportsStore(pinia)
app.provide("reportsStore", reportsStore)
const reportsStore = useReportsStore(pinia);
app.provide("reportsStore", reportsStore);
app.mount("#erm");

View file

@ -301,33 +301,43 @@ export const routes = [
{
path: "",
name: "UsageStatisticsDataProvidersList",
component: markRaw(UsageStatisticsDataProvidersList),
component: markRaw(
UsageStatisticsDataProvidersList
),
},
{
path: ":usage_data_provider_id",
name: "UsageStatisticsDataProvidersShow",
component: markRaw(UsageStatisticsDataProvidersShow),
title: $__("Show provider")
component: markRaw(
UsageStatisticsDataProvidersShow
),
title: $__("Show provider"),
},
{
path: "add",
name: "UsageStatisticsDataProvidersFormAdd",
component: markRaw(UsageStatisticsDataProvidersFormAdd),
title: $__("Add data provider")
component: markRaw(
UsageStatisticsDataProvidersFormAdd
),
title: $__("Add data provider"),
},
{
path: "edit/:usage_data_provider_id",
name: "UsageStatisticsDataProvidersFormAddEdit",
component: markRaw(UsageStatisticsDataProvidersFormAdd),
title: $__("Edit data provider")
component: markRaw(
UsageStatisticsDataProvidersFormAdd
),
title: $__("Edit data provider"),
},
{
path: "summary",
name: "UsageStatisticsDataProvidersSummary",
component: markRaw(UsageStatisticsDataProvidersSummary),
title: $__("Data providers summary")
component: markRaw(
UsageStatisticsDataProvidersSummary
),
title: $__("Data providers summary"),
},
]
],
},
{
path: "reports",
@ -343,13 +353,15 @@ export const routes = [
{
path: "viewer",
name: "UsageStatisticsReportsViewer",
component: markRaw(UsageStatisticsReportsViewer),
title: $__("View report")
}
]
}
]
}
component: markRaw(
UsageStatisticsReportsViewer
),
title: $__("View report"),
},
],
},
],
},
],
},
];
];

View file

@ -18,7 +18,7 @@
# 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;

View file

@ -1,24 +1,24 @@
import { mount } from "@cypress/vue"
import { mount } from "@cypress/vue";
describe("Reports home tabs", () => {
beforeEach(() => {
cy.login()
cy.title().should("eq", "Koha staff interface")
cy.login();
cy.title().should("eq", "Koha staff interface");
cy.intercept(
"GET",
"/cgi-bin/koha/svc/config/systempreferences/?pref=ERMModule",
'{"value":"1"}'
)
);
cy.intercept(
"GET",
"/cgi-bin/koha/svc/config/systempreferences/?pref=ERMProviders",
'{"value":"local"}'
)
);
const dataProvider = cy.get_usage_data_provider()
const dataProviders = [dataProvider]
const defaultReport = cy.get_default_report()
const defaulReports = [defaultReport]
const dataProvider = cy.get_usage_data_provider();
const dataProviders = [dataProvider];
const defaultReport = cy.get_default_report();
const defaulReports = [defaultReport];
cy.intercept("GET", "/api/v1/erm/usage_data_providers*", {
statusCode: 200,
@ -27,7 +27,7 @@ describe("Reports home tabs", () => {
"X-Base-Total-Count": "1",
"X-Total-Count": "1",
},
})
});
cy.intercept("GET", "/api/v1/erm/default_usage_reports*", {
statusCode: 200,
body: defaulReports,
@ -35,43 +35,47 @@ describe("Reports home tabs", () => {
"X-Base-Total-Count": "1",
"X-Total-Count": "1",
},
})
});
cy.visit("/cgi-bin/koha/erm/eusage/reports")
})
cy.visit("/cgi-bin/koha/erm/eusage/reports");
});
it("Should display the saved reports page", () => {
cy.get("#report_builder .default-report h2")
.should('have.text', "Select saved report")
})
cy.get("#report_builder .default-report h2").should(
"have.text",
"Select saved report"
);
});
it("Should display the custom report builder", () => {
cy.get("#usage_data_providerstabs").contains("Create report").click()
cy.get("#usage_data_providerstabs").contains("Create report").click();
cy.get("#report-builder h2")
.should('have.text', "Build a custom report")
})
})
cy.get("#report-builder h2").should(
"have.text",
"Build a custom report"
);
});
});
describe("Saved reports", () => {
beforeEach(() => {
cy.login()
cy.title().should("eq", "Koha staff interface")
cy.login();
cy.title().should("eq", "Koha staff interface");
cy.intercept(
"GET",
"/cgi-bin/koha/svc/config/systempreferences/?pref=ERMModule",
'{"value":"1"}'
)
);
cy.intercept(
"GET",
"/cgi-bin/koha/svc/config/systempreferences/?pref=ERMProviders",
'{"value":"local"}'
)
);
const dataProvider = cy.get_usage_data_provider()
const dataProviders = [dataProvider]
const defaultReport = cy.get_default_report()
const defaulReports = [defaultReport]
const dataProvider = cy.get_usage_data_provider();
const dataProviders = [dataProvider];
const defaultReport = cy.get_default_report();
const defaulReports = [defaultReport];
cy.intercept("GET", "/api/v1/erm/usage_data_providers*", {
statusCode: 200,
@ -80,7 +84,7 @@ describe("Saved reports", () => {
"X-Base-Total-Count": "1",
"X-Total-Count": "1",
},
})
});
cy.intercept("GET", "/api/v1/erm/default_usage_reports*", {
statusCode: 200,
body: defaulReports,
@ -88,57 +92,58 @@ describe("Saved reports", () => {
"X-Base-Total-Count": "1",
"X-Total-Count": "1",
},
})
});
cy.visit("/cgi-bin/koha/erm/eusage/reports")
})
cy.visit("/cgi-bin/koha/erm/eusage/reports");
});
it("Should correctly populate the dropdown menu", () => {
const defaultReport = cy.get_default_report()
const defaultReport = cy.get_default_report();
cy.get("#default_usage_reports .vs__open-indicator").click()
cy.get("#default_usage_reports .vs__open-indicator").click();
cy.get("#default_usage_reports .vs__dropdown-menu li:first").should(
"have.text", defaultReport.report_name
)
})
"have.text",
defaultReport.report_name
);
});
it("Should redirect to the reports viewer with the correct url params", () => {
const defaultReport = cy.get_default_report()
const defaultReport = cy.get_default_report();
cy.get("#default_usage_reports .vs__search").type(
defaultReport.report_name + "{enter}",
defaultReport.report_name + "{enter}",
{ force: true }
)
cy.get("#report_builder .default-report .action input").click()
);
cy.get("#report_builder .default-report .action input").click();
cy.url({ decode: true }).then(url => {
const urlParams = url.split('viewer?')[1].split('data=')[1]
const reportParams = defaultReport.report_url_params
const urlParams = url.split("viewer?")[1].split("data=")[1];
const reportParams = defaultReport.report_url_params;
expect(urlParams).to.eq(reportParams)
})
})
})
expect(urlParams).to.eq(reportParams);
});
});
});
describe("Custom reports", () => {
beforeEach(() => {
cy.login()
cy.title().should("eq", "Koha staff interface")
cy.login();
cy.title().should("eq", "Koha staff interface");
cy.intercept(
"GET",
"/cgi-bin/koha/svc/config/systempreferences/?pref=ERMModule",
'{"value":"1"}'
)
);
cy.intercept(
"GET",
"/cgi-bin/koha/svc/config/systempreferences/?pref=ERMProviders",
'{"value":"local"}'
)
);
const dataProviders = cy.get_multiple_providers()
const defaultReport = cy.get_default_report()
const defaultReports = [defaultReport]
const dataProviders = cy.get_multiple_providers();
const defaultReport = cy.get_default_report();
const defaultReports = [defaultReport];
cy.intercept("GET", "/api/v1/erm/usage_data_providers*", {
statusCode: 200,
@ -147,7 +152,7 @@ describe("Custom reports", () => {
"X-Base-Total-Count": "1",
"X-Total-Count": "1",
},
})
});
cy.intercept("GET", "/api/v1/erm/default_usage_reports*", {
statusCode: 200,
body: defaultReports,
@ -155,84 +160,79 @@ describe("Custom reports", () => {
"X-Base-Total-Count": "1",
"X-Total-Count": "1",
},
})
});
cy.visit("/cgi-bin/koha/erm/eusage/reports")
cy.get("#usage_data_providerstabs").contains("Create report").click()
})
cy.visit("/cgi-bin/koha/erm/eusage/reports");
cy.get("#usage_data_providerstabs").contains("Create report").click();
});
it("Should limit report types based on the provider(s) selected", () => {
const dataProviders = cy.get_multiple_providers()
cy.get('#report_type').find('.vs__actions').click()
cy.get('#report_type').find('li').as('options')
cy.get('@options').should('have.length', 16)
const dataProviders = cy.get_multiple_providers();
cy.get("#report_type").find(".vs__actions").click();
cy.get("#report_type").find("li").as("options");
cy.get("@options").should("have.length", 16);
cy.get("#usage_data_provider .vs__search").type(
dataProviders[0].name + "{enter}",
{ force: true }
)
cy.get('#report_type').find('.vs__actions').click()
cy.get('#report_type').find('li').as('options')
cy.get('@options').should('have.length', 1)
);
cy.get("#report_type").find(".vs__actions").click();
cy.get("#report_type").find("li").as("options");
cy.get("@options").should("have.length", 1);
cy.get("#usage_data_provider .vs__search").type(
dataProviders[1].name + "{enter}",
{ force: true }
)
cy.get('#report_type').find('.vs__actions').click()
cy.get('#report_type').find('li').as('options')
cy.get('@options').should('have.length', 3)
})
);
cy.get("#report_type").find(".vs__actions").click();
cy.get("#report_type").find("li").as("options");
cy.get("@options").should("have.length", 3);
});
it("Should limit data providers based on the report type(s) selected", () => {
cy.get('#usage_data_provider').find('.vs__actions').click()
cy.get('#usage_data_provider').find('li').as('options')
cy.get('@options').should('have.length', 2)
cy.get("#usage_data_provider").find(".vs__actions").click();
cy.get("#usage_data_provider").find("li").as("options");
cy.get("@options").should("have.length", 2);
cy.get("#report_type .vs__search").type(
"TR_J2" + "{enter}",
{ force: true }
)
cy.get('#usage_data_provider').find('.vs__actions').click()
cy.get('#usage_data_provider').find('li').as('options')
cy.get('@options').should('have.length', 1)
cy.get("#report_type .vs__search").type(
"TR_J1" + "{enter}",
{ force: true }
)
cy.get('#usage_data_provider').find('.vs__actions').click()
cy.get('#usage_data_provider').find('li').as('options')
cy.get('@options').should('have.length', 2)
})
cy.get("#report_type .vs__search").type("TR_J2" + "{enter}", {
force: true,
});
cy.get("#usage_data_provider").find(".vs__actions").click();
cy.get("#usage_data_provider").find("li").as("options");
cy.get("@options").should("have.length", 1);
cy.get("#report_type .vs__search").type("TR_J1" + "{enter}", {
force: true,
});
cy.get("#usage_data_provider").find(".vs__actions").click();
cy.get("#usage_data_provider").find("li").as("options");
cy.get("@options").should("have.length", 2);
});
it("Should limit metric types based on the report type(s) selected", () => {
cy.get("#metric_type .vs__search").should('be.disabled')
cy.get("#metric_type .vs__search").should("be.disabled");
cy.get("#report_type .vs__search").type(
"TR_J1" + "{enter}",
{ force: true }
)
cy.get('#metric_type').find('.vs__actions').click()
cy.get('#metric_type').find('li').as('options')
cy.get('@options').should('have.length', 2)
cy.get("#report_type .vs__search").type(
"PR" + "{enter}",
{ force: true }
)
cy.get('#metric_type').find('.vs__actions').click()
cy.get('#metric_type').find('li').as('options')
cy.get('@options').should('have.length', 7)
})
cy.get("#report_type .vs__search").type("TR_J1" + "{enter}", {
force: true,
});
cy.get("#metric_type").find(".vs__actions").click();
cy.get("#metric_type").find("li").as("options");
cy.get("@options").should("have.length", 2);
cy.get("#report_type .vs__search").type("PR" + "{enter}", {
force: true,
});
cy.get("#metric_type").find(".vs__actions").click();
cy.get("#metric_type").find("li").as("options");
cy.get("@options").should("have.length", 7);
});
it("Should disable the month selectors when a yearly report is selected", () => {
cy.get("#interval .vs__search").type(
"By year" + "{enter}",
{ force: true }
)
cy.get("#interval .vs__search").type("By year" + "{enter}", {
force: true,
});
cy.get("#start-month .vs__search").should('be.disabled')
cy.get("#end_month .vs__search").should('be.disabled')
})
})
cy.get("#start-month .vs__search").should("be.disabled");
cy.get("#end_month .vs__search").should("be.disabled");
});
});

View file

@ -23,7 +23,7 @@ use Koha::Database;
use Koha::BackgroundJobs;
use Koha::BackgroundJob::ErmSushiHarvester;
use JSON qw( decode_json );
use JSON qw( decode_json );
use File::Basename qw( dirname );
use File::Slurp;

View file

@ -22,7 +22,7 @@ use Test::More tests => 2;
use Koha::Database;
use Koha::ERM::EUsage::CounterFile;
use JSON qw( decode_json );
use JSON qw( decode_json );
use File::Basename qw( dirname );
use File::Slurp;

View file

@ -21,7 +21,7 @@ use Test::More tests => 15;
use Koha::ERM::EUsage::SushiCounter;
use Koha::Database;
use JSON qw( decode_json );
use JSON qw( decode_json );
use File::Basename qw( dirname );
use File::Slurp;
@ -803,8 +803,8 @@ subtest 'TR_B3 _COUNTER_report_body' => sub {
is( $report_body[8][10], '2002', '1st title, 2nd yop has 6 metric types' );
# The data is in the correct column
is( $report_body[2][0], 'Insect Cell Culture: Fundamental and Applied Aspects', '1st column is title' );
is( $report_body[2][1], 'Test Publisher', '2nd column is publisher' );
is( $report_body[2][0], 'Insect Cell Culture: Fundamental and Applied Aspects', '1st column is title' );
is( $report_body[2][1], 'Test Publisher', '2nd column is publisher' );
is( $report_body[2][2], '', '3rd column heading is publisher ID' );
is( $report_body[2][3], 'Test Platform', '4th column is platform' );
is( $report_body[2][4], '10.1007/0-306-46850-6', '5th column is DOI' );

View file

@ -30,7 +30,7 @@ use Koha::ERM::EUsage::SushiCounter;
use Koha::ERM::EUsage::MonthlyUsages;
use Koha::ERM::EUsage::YearlyUsages;
use JSON qw( decode_json );
use JSON qw( decode_json );
use File::Basename qw( dirname );
use File::Slurp;