View | Details | Raw Unified | Return to bug 39345
Collapse All | Expand All

(-)a/t/db_dependent/Koha/ERM/EUsage/COUNTER_5.1/CounterFile.t (+133 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# This file is part of Koha
4
#
5
# Koha is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# Koha is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
18
use Modern::Perl;
19
20
# use Test::NoWarnings;
21
use Test::More tests => 2;
22
23
use Koha::Database;
24
use Koha::ERM::EUsage::CounterFile;
25
26
use JSON           qw( decode_json );
27
use File::Basename qw( dirname );
28
use File::Slurp;
29
30
use t::lib::Mocks;
31
use t::lib::TestBuilder;
32
use Test::MockModule;
33
34
my $schema  = Koha::Database->new->schema;
35
my $builder = t::lib::TestBuilder->new;
36
37
my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
38
39
my $sushi_response_file_TR_J1       = dirname(__FILE__) . "/../../../../data/erm/eusage/COUNTER_5.1/TR_J1.json";
40
my $sushi_counter_51_response_TR_J1 = read_file($sushi_response_file_TR_J1);
41
my $sushi_counter_report_TR_J1 =
42
    Koha::ERM::EUsage::SushiCounter->new( { response => decode_json($sushi_counter_51_response_TR_J1) } );
43
44
subtest 'store' => sub {
45
46
    plan tests => 3;
47
48
    $schema->storage->txn_begin;
49
50
    my $patron = Koha::Patrons->search()->last;
51
    t::lib::Mocks::mock_userenv( { number => $patron->borrowernumber } );    # Is superlibrarian
52
53
    my $usage_data_provider = $builder->build_object(
54
        { class => 'Koha::ERM::EUsage::UsageDataProviders', value => { name => 'TestProvider' } } );
55
    $usage_data_provider->{report_type} = 'TR_J1';
56
57
    my $now_time = POSIX::strftime( "%Y%m%d%H%M%S", localtime );
58
59
    my $counter_file = Koha::ERM::EUsage::CounterFile->new(
60
        {
61
            usage_data_provider_id => $usage_data_provider->erm_usage_data_provider_id,
62
            file_content           => $sushi_counter_report_TR_J1->get_COUNTER_from_SUSHI,
63
            date_uploaded          => $now_time,
64
            filename               => $usage_data_provider->name . "_" . $usage_data_provider->{report_type},
65
        }
66
    )->store;
67
68
    # UsageTitles are added on CounterFile->store
69
    my $titles_rs = Koha::ERM::EUsage::UsageTitles->search(
70
        { usage_data_provider_id => $usage_data_provider->erm_usage_data_provider_id } );
71
72
    # MonthlyUsages are added on CounterFile->store
73
    my $mus_rs = Koha::ERM::EUsage::MonthlyUsages->search(
74
        { usage_data_provider_id => $usage_data_provider->erm_usage_data_provider_id } );
75
76
    # YearlyUsages are added on CounterFile->store
77
    my $yus_rs = Koha::ERM::EUsage::YearlyUsages->search(
78
        { usage_data_provider_id => $usage_data_provider->erm_usage_data_provider_id } );
79
80
    is( $titles_rs->count, 2,  '2 titles were added' );
81
    is( $mus_rs->count,    10, '10 monthly usages were added' );
82
    is( $yus_rs->count,    4,  '4 yearly usages were added' );
83
84
    $schema->storage->txn_rollback;
85
86
    #TODO: Test yop
87
    #TODO: acccess_type
88
89
};
90
91
subtest '_get_rows_from_COUNTER_file' => sub {
92
93
    plan tests => 4;
94
95
    $schema->storage->txn_begin;
96
97
    my $usage_data_provider = $builder->build_object(
98
        { class => 'Koha::ERM::EUsage::UsageDataProviders', value => { name => 'TestProvider' } } );
99
    $usage_data_provider->{report_type} = 'TR_J1';
100
101
    my $now_time = POSIX::strftime( "%Y%m%d%H%M%S", localtime );
102
103
    my $counter_file = $builder->build_object(
104
        {
105
            class => 'Koha::ERM::EUsage::CounterFiles',
106
            value => {
107
                usage_data_provider_id => $usage_data_provider->erm_usage_data_provider_id,
108
                file_content           => $sushi_counter_report_TR_J1->get_COUNTER_from_SUSHI,
109
                date_uploaded          => $now_time,
110
                filename               => $usage_data_provider->name . "_" . $usage_data_provider->{report_type},
111
            }
112
        }
113
    );
114
115
    my $counter_file_rows = $counter_file->_get_rows_from_COUNTER_file;
116
117
    is( ref $counter_file_rows, 'ARRAY', '_get_rows_from_COUNTER_file returns array' );
118
    is(
119
        scalar @{$counter_file_rows}, 4,
120
        '_get_rows_from_COUNTER_file returns correct number of rows'
121
    );
122
    is(
123
        @{$counter_file_rows}[0]->{Title}, 'Education and Training',
124
        'first and second report row is about the same title'
125
    );
126
    is(
127
        @{$counter_file_rows}[1]->{Title}, 'Education and Training',
128
        'first and second report row is about the same title'
129
    );
130
131
    $schema->storage->txn_rollback;
132
133
};
(-)a/t/db_dependent/Koha/ERM/EUsage/COUNTER_5.1/SushiCounter.t (+1031 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# This file is part of Koha
4
#
5
# Koha is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# Koha is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
18
use Modern::Perl;
19
20
# use Test::NoWarnings;
21
use Test::More tests => 18;
22
23
use Koha::ERM::EUsage::SushiCounter;
24
use Koha::Database;
25
use JSON           qw( decode_json );
26
use File::Basename qw( dirname );
27
use File::Slurp;
28
29
use t::lib::TestBuilder;
30
31
my $schema  = Koha::Database->new->schema;
32
my $builder = t::lib::TestBuilder->new;
33
34
my $test_data_base_dir              = "/../../../../data/erm/eusage/COUNTER_5.1";
35
my $sushi_response_file_TR_J1       = dirname(__FILE__) . $test_data_base_dir . "/TR_J1.json";
36
my $sushi_counter_51_response_TR_J1 = decode_json( read_file($sushi_response_file_TR_J1) );
37
my $sushi_counter_TR_J1 =
38
    Koha::ERM::EUsage::SushiCounter->new( { version => '5.1', response => $sushi_counter_51_response_TR_J1 } );
39
40
subtest 'TR_J1 _COUNTER_report_header' => sub {
41
42
    plan tests => 43;
43
44
    my @report_header = $sushi_counter_TR_J1->_COUNTER_report_header;
45
46
    # Header row #1 - Report_Name
47
    is( $report_header[0][0], 'Report_Name',                          '1st row is report name' );
48
    is( $report_header[0][1], 'Journal Requests (Excluding OA_Gold)', '1st row is report name' );
49
    is( $report_header[0][2], undef,                                  '1st row is report name' );
50
51
    # Header row #2 - Report_ID
52
    is( $report_header[1][0], 'Report_ID', '2nd row is report name' );
53
    is( $report_header[1][1], 'TR_J1',     '2nd row is report name' );
54
    is( $report_header[1][2], undef,       '2nd row is report name' );
55
56
    # Header row #3 - Release
57
    is( $report_header[2][0], 'Release', '3rd row is counter release' );
58
    is( $report_header[2][1], '5.1',     '3rd row is counter release' );
59
    is( $report_header[2][2], undef,     '3rd row is counter release' );
60
61
    # Header row #4 - Institution_Name
62
    is( $report_header[3][0], 'Institution_Name', '4th row is institution name' );
63
    is( $report_header[3][1], 'Test Institution', '4th row is institution name' );
64
    is( $report_header[3][2], undef,              '4th row is institution name' );
65
66
    # Header row #5 - Institution_ID
67
    is( $report_header[4][0], 'Institution_ID', '5th row is institution id' );
68
    like( $report_header[4][1], qr/Proprietary:TInsti:EALTEST001|ISNI:0000000123456789/, '5th row is institution id' );
69
    is( $report_header[4][2], undef, '5th row is institution id' );
70
71
    # Header row #6 - Metric_Types
72
    is( $report_header[5][0], 'Metric_Types',                              '6th row is metric types' );
73
    is( $report_header[5][1], 'Total_Item_Requests; Unique_Item_Requests', '6th row is metric types' );
74
    is( $report_header[5][2], undef,                                       '6th row is metric types' );
75
76
    # Header row #7 - Report_Filters
77
    is( $report_header[6][0], 'Report_Filters', '7th row is report filters' );
78
    like( $report_header[6][1], qr/End_Date:2022-09-30/,   '7th row is report filters' );
79
    like( $report_header[6][1], qr/Access_Method:Regular/, '7th row is report filters' );
80
    like(
81
        $report_header[6][1], qr/Metric_Type:Total_Item_Requests\|Unique_Item_Requests/,
82
        '7th row is report filters'
83
    );
84
    like( $report_header[6][1], qr/Data_Type:Journal/,      '7th row is report filters' );
85
    like( $report_header[6][1], qr/Begin_Date:2021-09-01/,  '7th row is report filters' );
86
    like( $report_header[6][1], qr/Access_Type:Controlled/, '7th row is report filters' );
87
    is( $report_header[6][2], undef, '7th row is report filters' );
88
89
    # Header row #8 - Report_Attributes
90
    is( $report_header[7][0], 'Report_Attributes', '8th row is report attributes' );
91
    is( $report_header[7][1], '',                  '8th row is report attributes' );
92
    is( $report_header[7][2], undef,               '8th row is report attributes' );
93
94
    # Header row #9 - Exceptions
95
    is( $report_header[8][0], 'Exceptions', '9th row is exceptions' );
96
    is( $report_header[8][1], '',           '9th row is exceptions' );
97
    is( $report_header[8][2], undef,        '9th row is exceptions' );
98
99
    # Header row #10 - Reporting_Period
100
    is( $report_header[9][0], 'Reporting_Period',                           '10th row is reporting period' );
101
    is( $report_header[9][1], 'Begin_Date=2021-09-01; End_Date=2022-09-30', '10th row is reporting period' );
102
    is( $report_header[9][2], undef,                                        '10th row is reporting period' );
103
104
    # Header row #11 - Created
105
    is( $report_header[10][0], 'Created',              '11th row is created' );
106
    is( $report_header[10][1], '2023-08-29T07:11:41Z', '11th row is created' );
107
    is( $report_header[10][2], undef,                  '11th row is created' );
108
109
    # Header row #12 - Created
110
    is( $report_header[11][0], 'Created_By',        '12th row is created by' );
111
    is( $report_header[11][1], 'Test Systems Inc.', '12th row is created by' );
112
    is( $report_header[11][2], undef,               '12th row is created by' );
113
114
    # Header row #13 - Registry_Record
115
    is( $report_header[12][0], 'Registry_Record', '13th row is empty' );
116
117
    # Header row #14 - This needs to be empty
118
    is( $report_header[13][0], '', '14th row is empty' );
119
};
120
121
subtest 'TR_J1 _COUNTER_report_column_headings' => sub {
122
123
    plan tests => 19;
124
125
    my @report_column_headings = $sushi_counter_TR_J1->_COUNTER_report_column_headings;
126
127
    # Standard TR_J1 column headings
128
    is( $report_column_headings[0][0],  'Title',                  '1st column heading is title' );
129
    is( $report_column_headings[0][1],  'Publisher',              '2nd column heading is publisher' );
130
    is( $report_column_headings[0][2],  'Publisher_ID',           '3rd column heading is publisher ID' );
131
    is( $report_column_headings[0][3],  'Platform',               '4th column heading is platform' );
132
    is( $report_column_headings[0][4],  'DOI',                    '5th column heading is DOI' );
133
    is( $report_column_headings[0][5],  'Proprietary_ID',         '6th column heading is proprietary ID' );
134
    is( $report_column_headings[0][6],  'Print_ISSN',             '7th column heading is print ISSN' );
135
    is( $report_column_headings[0][7],  'Online_ISSN',            '8th column heading is online ISSN' );
136
    is( $report_column_headings[0][8],  'URI',                    '9th column heading is URI' );
137
    is( $report_column_headings[0][9],  'Metric_Type',            '10th column heading is metric type' );
138
    is( $report_column_headings[0][10], 'Reporting_Period_Total', '11th column heading is reporting period total' );
139
140
    # Months column headings
141
    is( $report_column_headings[0][11], 'Sep 2021', '12th column is month column heading' );
142
    is( $report_column_headings[0][12], 'Oct 2021', '13th column is month column heading' );
143
    is( $report_column_headings[0][13], 'Nov 2021', '14th column is month column heading' );
144
    is( $report_column_headings[0][14], 'Dec 2021', '15th column is month column heading' );
145
    is( $report_column_headings[0][15], 'Jan 2022', '16th column is month column heading' );
146
    is( $report_column_headings[0][16], 'Feb 2022', '17th column is month column heading' );
147
148
    # ... period is september 2021 to september 2022, i.e. 13 months
149
    is( $report_column_headings[0][23], 'Sep 2022', '23rd column is the last month column heading' );
150
    is( $report_column_headings[0][24], undef,      '24th column is empty, no more months' );
151
};
152
153
subtest 'TR_J1 _COUNTER_report_body' => sub {
154
155
    plan tests => 16;
156
157
    my @report_body = $sushi_counter_TR_J1->_COUNTER_report_body;
158
159
    # The same title is sequential but for different metric types
160
    is( $report_body[0][0], 'Education and Training', 'same title, different metric type' );
161
    is( $report_body[1][0], 'Education and Training', 'same title, different metric type' );
162
    is( $report_body[0][9], 'Total_Item_Requests',    'same title, different metric type' );
163
    is( $report_body[1][9], 'Unique_Item_Requests',   'same title, different metric type' );
164
165
    # The data is in the correct column
166
    is( $report_body[2][0],  'Test Journal',            '1st column is title' );
167
    is( $report_body[2][1],  'Test Publisher',          '2nd column is publisher' );
168
    is( $report_body[2][2],  '0000000123456789',        '3rd column heading is publisher ID' );
169
    is( $report_body[2][3],  'Unit Test Library',       '4th column is platform' );
170
    is( $report_body[2][4],  '10.1002/(ISSN)1111-2222', '5th column is DOI' );
171
    is( $report_body[2][5],  'TInsti:ABC1',             '6th column is proprietary ID' );
172
    is( $report_body[2][6],  '7777-8888',               '7th column is print ISSN' );
173
    is( $report_body[2][7],  '5555-6666',               '8th column is online ISSN' );
174
    is( $report_body[2][8],  '',                        '9th column is URI' );
175
    is( $report_body[2][9],  'Total_Item_Requests',     '10th column is metric type' );
176
    is( $report_body[2][10], 2,                         '11th column is reporting period total' );
177
178
    # The period total is the sum of all the month columns
179
    my $stats_total = 0;
180
    for ( my $i = 11 ; $i < 24 ; $i++ ) {
181
        $stats_total += $report_body[0][$i];
182
    }
183
    is(
184
        $report_body[0][10], $stats_total,
185
        'Reporting period total matches the sum of all the monthly usage statistics'
186
    );
187
};
188
189
my $sushi_response_file_TR_J2       = dirname(__FILE__) . $test_data_base_dir . "/TR_J2.json";
190
my $sushi_counter_51_response_TR_J2 = decode_json( read_file($sushi_response_file_TR_J2) );
191
my $sushi_counter_TR_J2 = Koha::ERM::EUsage::SushiCounter->new( { response => $sushi_counter_51_response_TR_J2 } );
192
193
subtest 'TR_J2 _COUNTER_report_header' => sub {
194
195
    plan tests => 42;
196
197
    my @report_header = $sushi_counter_TR_J2->_COUNTER_report_header;
198
199
    # Header row #1 - Report_Name
200
    is( $report_header[0][0], 'Report_Name',           '1st row is report name' );
201
    is( $report_header[0][1], 'Journal Access Denied', '1st row is report name' );
202
    is( $report_header[0][2], undef,                   '1st row is report name' );
203
204
    # Header row #2 - Report_ID
205
    is( $report_header[1][0], 'Report_ID', '2nd row is report name' );
206
    is( $report_header[1][1], 'TR_J2',     '2nd row is report name' );
207
    is( $report_header[1][2], undef,       '2nd row is report name' );
208
209
    # Header row #3 - Release
210
    is( $report_header[2][0], 'Release', '3rd row is counter release' );
211
    is( $report_header[2][1], '5.1',     '3rd row is counter release' );
212
    is( $report_header[2][2], undef,     '3rd row is counter release' );
213
214
    # Header row #4 - Institution_Name
215
    is( $report_header[3][0], 'Institution_Name',   '4th row is institution name' );
216
    is( $report_header[3][1], 'Sample Institution', '4th row is institution name' );
217
    is( $report_header[3][2], undef,                '4th row is institution name' );
218
219
    # Header row #5 - Institution_ID
220
    is( $report_header[4][0], 'Institution_ID',        '5th row is institution id' );
221
    is( $report_header[4][1], 'ISNI:1234123412341234', '5th row is institution id' );
222
    is( $report_header[4][2], undef,                   '5th row is institution id' );
223
224
    # Header row #6 - Metric_Types
225
    is( $report_header[5][0], 'Metric_Types',               '6th row is metric types' );
226
    is( $report_header[5][1], 'Limit_Exceeded; No_License', '6th row is metric types' );
227
    is( $report_header[5][2], undef,                        '6th row is metric types' );
228
229
    # Header row #7 - Report_Filters
230
    is( $report_header[6][0], 'Report_Filters', '7th row is report filters' );
231
    like( $report_header[6][1], qr/Metric_Type:Limit_Exceeded\|No_License/, '7th row is report filters' );
232
    like( $report_header[6][1], qr/Begin_Date:2022-01-01/,                  '7th row is report filters' );
233
    like( $report_header[6][1], qr/End_Date:2022-03-31/,                    '7th row is report filters' );
234
    like( $report_header[6][1], qr/Access_Method:Regular/,                  '7th row is report filters' );
235
    like( $report_header[6][1], qr/Data_Type:Journal/,                      '7th row is report filters' );
236
237
    is( $report_header[6][2], undef, '7th row is report filters' );
238
239
    # Header row #8 - Report_Attributes
240
    is( $report_header[7][0], 'Report_Attributes', '8th row is report attributes' );
241
    is( $report_header[7][1], '',                  '8th row is report attributes' );
242
    is( $report_header[7][2], undef,               '8th row is report attributes' );
243
244
    # Header row #9 - Exceptions
245
    is( $report_header[8][0], 'Exceptions', '9th row is exceptions' );
246
    is( $report_header[8][1], '',           '9th row is exceptions' );
247
    is( $report_header[8][2], undef,        '9th row is exceptions' );
248
249
    # Header row #10 - Reporting_Period
250
    is( $report_header[9][0], 'Reporting_Period',                           '10th row is reporting period' );
251
    is( $report_header[9][1], 'Begin_Date=2022-01-01; End_Date=2022-03-31', '10th row is reporting period' );
252
    is( $report_header[9][2], undef,                                        '10th row is reporting period' );
253
254
    # Header row #11 - Created
255
    is( $report_header[10][0], 'Created',              '11th row is created' );
256
    is( $report_header[10][1], '2023-02-15T09:11:12Z', '11th row is created' );
257
    is( $report_header[10][2], undef,                  '11th row is created' );
258
259
    # Header row #12 - Created
260
    is( $report_header[11][0], 'Created_By',       '12th row is created by' );
261
    is( $report_header[11][1], 'Sample Publisher', '12th row is created by' );
262
    is( $report_header[11][2], undef,              '12th row is created by' );
263
264
    # Header row #13 - Registry_Record
265
    is( $report_header[12][0], 'Registry_Record', '13th row is Registry_Record' );
266
267
    # Header row #14 - This needs to be empty
268
    is( $report_header[13][0], '', '14th row is empty' );
269
};
270
271
subtest 'TR_J2 _COUNTER_report_column_headings' => sub {
272
273
    plan tests => 15;
274
275
    my @report_column_headings = $sushi_counter_TR_J2->_COUNTER_report_column_headings;
276
277
    # Standard TR_J2 column headings
278
    is( $report_column_headings[0][0],  'Title',                  '1st column heading is title' );
279
    is( $report_column_headings[0][1],  'Publisher',              '2nd column heading is publisher' );
280
    is( $report_column_headings[0][2],  'Publisher_ID',           '3rd column heading is publisher ID' );
281
    is( $report_column_headings[0][3],  'Platform',               '4th column heading is platform' );
282
    is( $report_column_headings[0][4],  'DOI',                    '5th column heading is DOI' );
283
    is( $report_column_headings[0][5],  'Proprietary_ID',         '6th column heading is proprietary ID' );
284
    is( $report_column_headings[0][6],  'Print_ISSN',             '7th column heading is print ISSN' );
285
    is( $report_column_headings[0][7],  'Online_ISSN',            '8th column heading is online ISSN' );
286
    is( $report_column_headings[0][8],  'URI',                    '9th column heading is URI' );
287
    is( $report_column_headings[0][9],  'Metric_Type',            '10th column heading is metric type' );
288
    is( $report_column_headings[0][10], 'Reporting_Period_Total', '11th column heading is reporting period total' );
289
290
    # Months column headings
291
    is( $report_column_headings[0][11], 'Jan 2022', '12th column is month column heading' );
292
    is( $report_column_headings[0][12], 'Feb 2022', '13th column is another month column heading' );
293
    is( $report_column_headings[0][13], 'Mar 2022', '14th column is the last month column heading' );
294
    is( $report_column_headings[0][14], undef,      '15th column is empty, no more months' );
295
};
296
297
subtest 'TR_J2 _COUNTER_report_body' => sub {
298
299
    plan tests => 16;
300
301
    my @report_body = $sushi_counter_TR_J2->_COUNTER_report_body;
302
303
    # The same title is sequential but for different metric types
304
    is( $report_body[0][0], 'Title 3',        'same title, different metric type' );
305
    is( $report_body[1][0], 'Title 3',        'same title, same metric type' );
306
    is( $report_body[0][9], 'Limit_Exceeded', '1st title, different metric_type' );
307
    is( $report_body[1][9], 'No_License',     '1sd title, different metric_type' );
308
309
    # The data is in the correct column
310
    is( $report_body[2][0],  'Another title',     '1st column is title' );
311
    is( $report_body[2][1],  'Another publisher', '2nd column is publisher' );
312
    is( $report_body[2][2],  '4321432143214321',  '3rd column is publisher ID and shows because there is ISNI' );
313
    is( $report_body[2][3],  'Platform 1',        '4th column is platform' );
314
    is( $report_body[2][4],  '10.9999/xxxxt03',   '5th column is DOI' );
315
    is( $report_body[2][5],  'P1:T03',            '6th column is proprietary ID' );
316
    is( $report_body[2][6],  '',                  '7th column is print ISSN' );
317
    is( $report_body[2][7],  '1234-4321',         '8th column is online ISSN' );
318
    is( $report_body[2][8],  '',                  '9th column is URI' );
319
    is( $report_body[2][9],  'Limit_Exceeded',    '10th column is metric type' );
320
    is( $report_body[2][10], 388,                 '11th column is reporting period total' );
321
322
    # The period total is the sum of all the month columns
323
    my $stats_total = 0;
324
    for ( my $i = 11 ; $i < 14 ; $i++ ) {
325
        $stats_total += $report_body[0][$i];
326
    }
327
328
    is(
329
        $report_body[0][10], $stats_total,
330
        'Reporting period total matches the sum of all the monthly usage statistics'
331
    );
332
};
333
334
my $sushi_response_file_TR_J3       = dirname(__FILE__) . $test_data_base_dir . "/TR_J3.json";
335
my $sushi_counter_51_response_TR_J3 = decode_json( read_file($sushi_response_file_TR_J3) );
336
my $sushi_counter_TR_J3 = Koha::ERM::EUsage::SushiCounter->new( { response => $sushi_counter_51_response_TR_J3 } );
337
338
subtest 'TR_J3 _COUNTER_report_header' => sub {
339
340
    plan tests => 42;
341
342
    my @report_header = $sushi_counter_TR_J3->_COUNTER_report_header;
343
344
    # Header row #1 - Report_Name
345
    is( $report_header[0][0], 'Report_Name',                  '1st row is report name' );
346
    is( $report_header[0][1], 'Journal Usage by Access Type', '1st row is report name' );
347
    is( $report_header[0][2], undef,                          '1st row is report name' );
348
349
    # Header row #2 - Report_ID
350
    is( $report_header[1][0], 'Report_ID', '2nd row is report name' );
351
    is( $report_header[1][1], 'TR_J3',     '2nd row is report name' );
352
    is( $report_header[1][2], undef,       '2nd row is report name' );
353
354
    # Header row #3 - Release
355
    is( $report_header[2][0], 'Release', '3rd row is counter release' );
356
    is( $report_header[2][1], '5.1',     '3rd row is counter release' );
357
    is( $report_header[2][2], undef,     '3rd row is counter release' );
358
359
    # Header row #4 - Institution_Name
360
    is( $report_header[3][0], 'Institution_Name',   '4th row is institution name' );
361
    is( $report_header[3][1], 'Sample Institution', '4th row is institution name' );
362
    is( $report_header[3][2], undef,                '4th row is institution name' );
363
364
    # Header row #5 - Institution_ID
365
    is( $report_header[4][0], 'Institution_ID',        '5th row is institution id' );
366
    is( $report_header[4][1], 'ISNI:1234123412341234', '5th row is institution id' );
367
    is( $report_header[4][2], undef,                   '5th row is institution id' );
368
369
    # Header row #6 - Metric_Types
370
    is( $report_header[5][0], 'Metric_Types', '6th row is metric types' );
371
    is(
372
        $report_header[5][1],
373
        'Total_Item_Investigations; Total_Item_Requests; Unique_Item_Investigations; Unique_Item_Requests',
374
        '6th row is metric types'
375
    );
376
    is( $report_header[5][2], undef, '6th row is metric types' );
377
378
    # Header row #7 - Report_Filters
379
    is( $report_header[6][0], 'Report_Filters', '7th row is report filters' );
380
    like(
381
        $report_header[6][1],
382
        qr/Metric_Type:Total_Item_Investigations\|Total_Item_Requests\|Unique_Item_Investigations\|Unique_Item_Requests/,
383
        '7th row is report filters'
384
    );
385
    like( $report_header[6][1], qr/Access_Method:Regular/, '7th row is report filters' );
386
    like( $report_header[6][1], qr/End_Date:2022-03-31/,   '7th row is report filters' );
387
    like( $report_header[6][1], qr/Data_Type:Journal/,     '7th row is report filters' );
388
    like( $report_header[6][1], qr/Begin_Date:2022-01-01/, '7th row is report filters' );
389
390
    is( $report_header[6][2], undef, '7th row is report filters' );
391
392
    # Header row #8 - Report_Attributes
393
    is( $report_header[7][0], 'Report_Attributes', '8th row is report attributes' );
394
    is( $report_header[7][1], '',                  '8th row is report attributes' );
395
    is( $report_header[7][2], undef,               '8th row is report attributes' );
396
397
    # Header row #9 - Exceptions
398
    is( $report_header[8][0], 'Exceptions', '9th row is exceptions' );
399
    is( $report_header[8][1], '',           '9th row is exceptions' );
400
    is( $report_header[8][2], undef,        '9th row is exceptions' );
401
402
    # Header row #10 - Reporting_Period
403
    is( $report_header[9][0], 'Reporting_Period',                           '10th row is reporting period' );
404
    is( $report_header[9][1], 'Begin_Date=2022-01-01; End_Date=2022-03-31', '10th row is reporting period' );
405
    is( $report_header[9][2], undef,                                        '10th row is reporting period' );
406
407
    # Header row #11 - Created
408
    is( $report_header[10][0], 'Created',              '11th row is created' );
409
    is( $report_header[10][1], '2023-02-15T09:11:12Z', '11th row is created' );
410
    is( $report_header[10][2], undef,                  '11th row is created' );
411
412
    # Header row #12 - Created
413
    is( $report_header[11][0], 'Created_By',       '12th row is created by' );
414
    is( $report_header[11][1], 'Sample Publisher', '12th row is created by' );
415
    is( $report_header[11][2], undef,              '12th row is created by' );
416
417
    # Header row #13 - Registry_Record
418
    is( $report_header[12][0], 'Registry_Record', '13th row is Registry_Record' );
419
420
    # Header row #14 - This needs to be empty
421
    is( $report_header[13][0], '', '14th row is empty' );
422
};
423
424
subtest 'TR_J3 _COUNTER_report_column_headings' => sub {
425
426
    plan tests => 16;
427
428
    my @report_column_headings = $sushi_counter_TR_J3->_COUNTER_report_column_headings;
429
430
    # Standard TR_J3 column headings
431
    is( $report_column_headings[0][0],  'Title',                  '1st column heading is title' );
432
    is( $report_column_headings[0][1],  'Publisher',              '2nd column heading is publisher' );
433
    is( $report_column_headings[0][2],  'Publisher_ID',           '3rd column heading is publisher ID' );
434
    is( $report_column_headings[0][3],  'Platform',               '4th column heading is platform' );
435
    is( $report_column_headings[0][4],  'DOI',                    '5th column heading is DOI' );
436
    is( $report_column_headings[0][5],  'Proprietary_ID',         '6th column heading is proprietary ID' );
437
    is( $report_column_headings[0][6],  'Print_ISSN',             '7th column heading is print ISSN' );
438
    is( $report_column_headings[0][7],  'Online_ISSN',            '8th column heading is online ISSN' );
439
    is( $report_column_headings[0][8],  'URI',                    '9th column heading is URI' );
440
    is( $report_column_headings[0][9],  'Access_Type',            '10th column heading is access type' );
441
    is( $report_column_headings[0][10], 'Metric_Type',            '11th column heading is access type' );
442
    is( $report_column_headings[0][11], 'Reporting_Period_Total', '12th column heading is reporting period total' );
443
444
    # Months column headings
445
    is( $report_column_headings[0][12], 'Jan 2022', '12th column is month column heading' );
446
    is( $report_column_headings[0][13], 'Feb 2022', '13th column is another month column heading' );
447
    is( $report_column_headings[0][14], 'Mar 2022', '13th column is the last month column heading' );
448
    is( $report_column_headings[0][25], undef,      '14th column is empty, no more months' );
449
};
450
451
subtest 'TR_J3 _COUNTER_report_body' => sub {
452
453
    plan tests => 25;
454
455
    my @report_body = $sushi_counter_TR_J3->_COUNTER_report_body;
456
457
    # The same title is sequential but for different metric types
458
    is( $report_body[0][0],  'Title 3',                    'same title, different metric type' );
459
    is( $report_body[1][0],  'Title 3',                    'same title, different metric type' );
460
    is( $report_body[2][0],  'Title 3',                    'same title, different metric type' );
461
    is( $report_body[3][0],  'Title 3',                    'same title, different metric type' );
462
    is( $report_body[0][9],  'Controlled',                 'same title, same access_type' );
463
    is( $report_body[1][9],  'Controlled',                 'same title, same access_type' );
464
    is( $report_body[2][9],  'Controlled',                 'same title, same access_type' );
465
    is( $report_body[3][9],  'Controlled',                 'same title, same access_type' );
466
    is( $report_body[0][10], 'Total_Item_Investigations',  'same title, different metric type' );
467
    is( $report_body[1][10], 'Total_Item_Requests',        'same title, different metric type' );
468
    is( $report_body[2][10], 'Unique_Item_Investigations', 'same title, different metric type' );
469
    is( $report_body[3][10], 'Unique_Item_Requests',       'same title, different metric type' );
470
471
    # The data is in the correct column
472
    is( $report_body[2][0],  'Title 3',                    '1st column is title' );
473
    is( $report_body[2][1],  'Sample Publisher',           '2nd column is publisher' );
474
    is( $report_body[2][2],  '4321432143214321',           '3rd column is publisher ID' );
475
    is( $report_body[2][3],  'Platform 1',                 '4th column is platform' );
476
    is( $report_body[2][4],  '10.9999/xxxxt03',            '5th column is DOI' );
477
    is( $report_body[2][5],  'P1:T03',                     '6th column is proprietary ID' );
478
    is( $report_body[2][6],  '',                           '7th column is print ISSN' );
479
    is( $report_body[2][7],  '1234-4321',                  '8th column is online ISSN' );
480
    is( $report_body[2][8],  '',                           '9th column is URI' );
481
    is( $report_body[2][9],  'Controlled',                 '10th column is access type' );
482
    is( $report_body[2][10], 'Unique_Item_Investigations', '11th column is metric type' );
483
    is( $report_body[2][11], 1602,                         '12th column is reporting period total' );    # 608+618+376
484
485
    # The period total is the sum of all the month columns
486
    my $stats_total = 0;
487
    for ( my $i = 12 ; $i < 15 ; $i++ ) {
488
        $stats_total += $report_body[0][$i];
489
    }
490
    is(
491
        $report_body[0][11], $stats_total,
492
        'Reporting period total matches the sum of all the monthly usage statistics'
493
    );
494
};
495
496
my $sushi_response_file_TR_J4       = dirname(__FILE__) . $test_data_base_dir . "/TR_J4.json";
497
my $sushi_counter_51_response_TR_J4 = decode_json( read_file($sushi_response_file_TR_J4) );
498
my $sushi_counter_TR_J4 = Koha::ERM::EUsage::SushiCounter->new( { response => $sushi_counter_51_response_TR_J4 } );
499
500
subtest 'TR_J4 _COUNTER_report_header' => sub {
501
502
    plan tests => 43;
503
504
    my @report_header = $sushi_counter_TR_J4->_COUNTER_report_header;
505
506
    # Header row #1 - Report_Name
507
    is( $report_header[0][0], 'Report_Name',                          '1st row is report name' );
508
    is( $report_header[0][1], 'Journal Requests by YOP (Controlled)', '1st row is report name' );
509
    is( $report_header[0][2], undef,                                  '1st row is report name' );
510
511
    # Header row #2 - Report_ID
512
    is( $report_header[1][0], 'Report_ID', '2nd row is report name' );
513
    is( $report_header[1][1], 'TR_J4',     '2nd row is report name' );
514
    is( $report_header[1][2], undef,       '2nd row is report name' );
515
516
    # Header row #3 - Release
517
    is( $report_header[2][0], 'Release', '3rd row is counter release' );
518
    is( $report_header[2][1], '5.1',     '3rd row is counter release' );
519
    is( $report_header[2][2], undef,     '3rd row is counter release' );
520
521
    # Header row #4 - Institution_Name
522
    is( $report_header[3][0], 'Institution_Name',   '4th row is institution name' );
523
    is( $report_header[3][1], 'Sample Institution', '4th row is institution name' );
524
    is( $report_header[3][2], undef,                '4th row is institution name' );
525
526
    # Header row #5 - Institution_ID
527
    is( $report_header[4][0], 'Institution_ID',        '5th row is institution id' );
528
    is( $report_header[4][1], 'ISNI:1234123412341234', '5th row is institution id' );
529
    is( $report_header[4][2], undef,                   '5th row is institution id' );
530
531
    # Header row #6 - Metric_Types
532
    is( $report_header[5][0], 'Metric_Types', '6th row is metric types' );
533
    is(
534
        $report_header[5][1],
535
        'Total_Item_Requests; Unique_Item_Requests',
536
        '6th row is metric types'
537
    );
538
    is( $report_header[5][2], undef, '6th row is metric types' );
539
540
    # Header row #7 - Report_Filters
541
    is( $report_header[6][0], 'Report_Filters', '7th row is report filters' );
542
    like( $report_header[6][1], qr/Metric_Type:Total_Item_Requests|Unique_Item_Requests/, '7th row is report filters' );
543
    like( $report_header[6][1], qr/Access_Method:Regular/,                                '7th row is report filters' );
544
    like( $report_header[6][1], qr/Begin_Date:2022-01-01/,                                '7th row is report filters' );
545
    like( $report_header[6][1], qr/Access_Type:Controlled/,                               '7th row is report filters' );
546
    like( $report_header[6][1], qr/End_Date:2022-03-31/,                                  '7th row is report filters' );
547
    like( $report_header[6][1], qr/Data_Type:Journal/,                                    '7th row is report filters' );
548
549
    is( $report_header[6][2], undef, '7th row is report filters' );
550
551
    # Header row #8 - Report_Attributes
552
    is( $report_header[7][0], 'Report_Attributes', '8th row is report attributes' );
553
    is( $report_header[7][1], '',                  '8th row is report attributes' );
554
    is( $report_header[7][2], undef,               '8th row is report attributes' );
555
556
    # Header row #9 - Exceptions
557
    is( $report_header[8][0], 'Exceptions', '9th row is exceptions' );
558
    is( $report_header[8][1], '',           '9th row is exceptions' );
559
    is( $report_header[8][2], undef,        '9th row is exceptions' );
560
561
    # Header row #10 - Reporting_Period
562
    is( $report_header[9][0], 'Reporting_Period',                           '10th row is reporting period' );
563
    is( $report_header[9][1], 'Begin_Date=2022-01-01; End_Date=2022-03-31', '10th row is reporting period' );
564
    is( $report_header[9][2], undef,                                        '10th row is reporting period' );
565
566
    # Header row #11 - Created
567
    is( $report_header[10][0], 'Created',              '11th row is created' );
568
    is( $report_header[10][1], '2023-02-15T09:11:12Z', '11th row is created' );
569
    is( $report_header[10][2], undef,                  '11th row is created' );
570
571
    # Header row #12 - Created
572
    is( $report_header[11][0], 'Created_By',       '12th row is created by' );
573
    is( $report_header[11][1], 'Sample Publisher', '12th row is created by' );
574
    is( $report_header[11][2], undef,              '12th row is created by' );
575
576
    # Header row #13 - Registry_Record
577
    is( $report_header[12][0], 'Registry_Record', '13th row is Registry_Record' );
578
579
    # Header row #14 - This needs to be empty
580
    is( $report_header[13][0], '', '14th row is empty' );
581
};
582
583
subtest 'TR_J4 _COUNTER_report_column_headings' => sub {
584
585
    plan tests => 16;
586
587
    my @report_column_headings = $sushi_counter_TR_J4->_COUNTER_report_column_headings;
588
589
    # Standard TR_J4 column headings
590
    is( $report_column_headings[0][0],  'Title',                  '1st column heading is title' );
591
    is( $report_column_headings[0][1],  'Publisher',              '2nd column heading is publisher' );
592
    is( $report_column_headings[0][2],  'Publisher_ID',           '3rd column heading is publisher ID' );
593
    is( $report_column_headings[0][3],  'Platform',               '4th column heading is platform' );
594
    is( $report_column_headings[0][4],  'DOI',                    '5th column heading is DOI' );
595
    is( $report_column_headings[0][5],  'Proprietary_ID',         '6th column heading is proprietary ID' );
596
    is( $report_column_headings[0][6],  'Print_ISSN',             '7th column heading is print ISSN' );
597
    is( $report_column_headings[0][7],  'Online_ISSN',            '8th column heading is online ISSN' );
598
    is( $report_column_headings[0][8],  'URI',                    '9th column heading is URI' );
599
    is( $report_column_headings[0][9],  'YOP',                    '10th column heading is yop' );
600
    is( $report_column_headings[0][10], 'Metric_Type',            '11th column heading is metric type' );
601
    is( $report_column_headings[0][11], 'Reporting_Period_Total', '12th column heading is reporting period total' );
602
603
    # Months column headings
604
    is( $report_column_headings[0][12], 'Jan 2022', '13th column is month column heading' );
605
    is( $report_column_headings[0][13], 'Feb 2022', '14th column is another month column heading' );
606
    is( $report_column_headings[0][14], 'Mar 2022', '15th column is the last month column heading' );
607
    is( $report_column_headings[0][15], undef,      '16th column is empty, no more months' );
608
};
609
610
subtest 'TR_J4 _COUNTER_report_body' => sub {
611
612
    plan tests => 25;
613
614
    my @report_body = $sushi_counter_TR_J4->_COUNTER_report_body;
615
616
    # The same title is sequential but for different metric types
617
    is( $report_body[0][0],  'Title 3',              'same title, different metric type' );
618
    is( $report_body[1][0],  'Title 3',              'same title, different metric type' );
619
    is( $report_body[2][0],  'Title 3',              'same title, different metric type' );
620
    is( $report_body[3][0],  'Title 3',              'same title, different metric type' );
621
    is( $report_body[0][10], 'Total_Item_Requests',  '1st title, same yop' );
622
    is( $report_body[1][10], 'Unique_Item_Requests', '1st title, same yop' );
623
    is( $report_body[2][10], 'Total_Item_Requests',  '1st title, same yop' );
624
    is( $report_body[3][10], 'Unique_Item_Requests', '1st title, same yop' );
625
    is( $report_body[0][9],  '2022',                 '1st title, yop' );
626
    is( $report_body[1][9],  '2022',                 '1st title, yop' );
627
    is( $report_body[2][9],  '2021',                 '1st title, yop' );
628
    is( $report_body[3][9],  '2021',                 '1st title, yop' );
629
630
    # The data is in the correct column
631
    is( $report_body[2][0],  'Title 3',             '1st column is title' );
632
    is( $report_body[2][1],  'Sample Publisher',    '2nd column is publisher' );
633
    is( $report_body[2][2],  '4321432143214321',    '3rd column is publisher ID' );
634
    is( $report_body[2][3],  'Platform 1',          '4th column is platform' );
635
    is( $report_body[2][4],  '10.9999/xxxxt03',     '5th column is DOI' );
636
    is( $report_body[2][5],  'P1:T03',              '6th column is proprietary ID' );
637
    is( $report_body[2][6],  '',                    '7th column is print ISSN' );
638
    is( $report_body[2][7],  '1234-4321',           '8th column is online ISSN' );
639
    is( $report_body[2][8],  '',                    '9th column is URI' );
640
    is( $report_body[2][9],  '2021',                '10th column is yop' );
641
    is( $report_body[2][10], 'Total_Item_Requests', '10th column is metric type' );
642
    is( $report_body[2][11], 640,                   '11th column is reporting period total' );    #150+247+243
643
644
    # The period total is the sum of all the month columns
645
    my $stats_total = 0;
646
    for ( my $i = 12 ; $i < 15 ; $i++ ) {
647
        $stats_total += $report_body[0][$i];
648
    }
649
    is(
650
        $report_body[0][11], $stats_total,
651
        'Reporting period total matches the sum of all the monthly usage statistics'
652
    );
653
};
654
655
my $sushi_response_file_TR_B3       = dirname(__FILE__) . $test_data_base_dir . "/TR_B3.json";
656
my $sushi_counter_51_response_TR_B3 = decode_json( read_file($sushi_response_file_TR_B3) );
657
my $sushi_counter_TR_B3 = Koha::ERM::EUsage::SushiCounter->new( { response => $sushi_counter_51_response_TR_B3 } );
658
659
subtest 'TR_B3 _COUNTER_report_header' => sub {
660
661
    plan tests => 47;
662
663
    my @report_header = $sushi_counter_TR_B3->_COUNTER_report_header;
664
665
    # Header row #1 - Report_Name
666
    is( $report_header[0][0], 'Report_Name',               '1st row is report name' );
667
    is( $report_header[0][1], 'Book Usage by Access Type', '1st row is report name' );
668
    is( $report_header[0][2], undef,                       '1st row is report name' );
669
670
    # Header row #2 - Report_ID
671
    is( $report_header[1][0], 'Report_ID', '2nd row is report name' );
672
    is( $report_header[1][1], 'TR_B3',     '2nd row is report name' );
673
    is( $report_header[1][2], undef,       '2nd row is report name' );
674
675
    # Header row #3 - Release
676
    is( $report_header[2][0], 'Release', '3rd row is counter release' );
677
    is( $report_header[2][1], '5.1',     '3rd row is counter release' );
678
    is( $report_header[2][2], undef,     '3rd row is counter release' );
679
680
    # Header row #4 - Institution_Name
681
    is( $report_header[3][0], 'Institution_Name',   '4th row is institution name' );
682
    is( $report_header[3][1], 'Sample Institution', '4th row is institution name' );
683
    is( $report_header[3][2], undef,                '4th row is institution name' );
684
685
    # Header row #5 - Institution_ID
686
    is( $report_header[4][0], 'Institution_ID',        '5th row is institution id' );
687
    is( $report_header[4][1], 'ISNI:1234123412341234', '5th row is institution id' );
688
    is( $report_header[4][2], undef,                   '5th row is institution id' );
689
690
    # Header row #6 - Metric_Types
691
    is( $report_header[5][0], 'Metric_Types', '6th row is metric types' );
692
    like( $report_header[5][1], qr/Total_Item_Investigations/,   '6th row is metric types' );
693
    like( $report_header[5][1], qr/Total_Item_Requests/,         '6th row is metric types' );
694
    like( $report_header[5][1], qr/Unique_Item_Investigations/,  '6th row is metric types' );
695
    like( $report_header[5][1], qr/Unique_Item_Requests/,        '6th row is metric types' );
696
    like( $report_header[5][1], qr/Unique_Title_Investigations/, '6th row is metric types' );
697
    like( $report_header[5][1], qr/Unique_Title_Requests/,       '6th row is metric types' );
698
699
    is( $report_header[5][2], undef, '6th row is metric types' );
700
701
    # Header row #7 - Report_Filters
702
    is( $report_header[6][0], 'Report_Filters', '7th row is report filters' );
703
    like( $report_header[6][1], qr/Data_Type:Book/,        '7th row is report filters' );
704
    like( $report_header[6][1], qr/Access_Method:Regular/, '7th row is report filters' );
705
    like(
706
        $report_header[6][1],
707
        qr/Metric_Type:Total_Item_Investigations\|Total_Item_Requests\|Unique_Item_Investigations\|Unique_Item_Requests\|Unique_Title_Investigations\|Unique_Title_Requests/,
708
        '7th row is report filters'
709
    );
710
    like( $report_header[6][1], qr/Begin_Date:2022-01-01/, '7th row is report filters' );
711
    like( $report_header[6][1], qr/End_Date:2022-03-31/,   '7th row is report filters' );
712
713
    is( $report_header[6][2], undef, '7th row is report filters' );
714
715
    # Header row #8 - Report_Attributes
716
    is( $report_header[7][0], 'Report_Attributes', '8th row is report attributes' );
717
    is( $report_header[7][1], '',                  '8th row is report attributes' );
718
    is( $report_header[7][2], undef,               '8th row is report attributes' );
719
720
    # Header row #9 - Exceptions
721
    is( $report_header[8][0], 'Exceptions', '9th row is exceptions' );
722
    is( $report_header[8][1], '',           '9th row is exceptions' );
723
    is( $report_header[8][2], undef,        '9th row is exceptions' );
724
725
    # Header row #10 - Reporting_Period
726
    is( $report_header[9][0], 'Reporting_Period',                           '10th row is reporting period' );
727
    is( $report_header[9][1], 'Begin_Date=2022-01-01; End_Date=2022-03-31', '10th row is reporting period' );
728
    is( $report_header[9][2], undef,                                        '10th row is reporting period' );
729
730
    # Header row #11 - Created
731
    is( $report_header[10][0], 'Created',              '11th row is created' );
732
    is( $report_header[10][1], '2023-02-15T09:11:12Z', '11th row is created' );
733
    is( $report_header[10][2], undef,                  '11th row is created' );
734
735
    # Header row #12 - Created
736
    is( $report_header[11][0], 'Created_By',       '12th row is created by' );
737
    is( $report_header[11][1], 'Sample Publisher', '12th row is created by' );
738
    is( $report_header[11][2], undef,              '12th row is created by' );
739
740
    # Header row #13 - Registry_Record
741
    is( $report_header[12][0], 'Registry_Record', '13th row is Registry_Record' );
742
743
    # Header row #14 - This needs to be empty
744
    is( $report_header[13][0], '', '14th row is empty' );
745
};
746
747
subtest 'TR_B3 _COUNTER_report_column_headings' => sub {
748
749
    plan tests => 19;
750
751
    my @report_column_headings = $sushi_counter_TR_B3->_COUNTER_report_column_headings;
752
753
    # Standard TR_J4 column headings
754
    is( $report_column_headings[0][0],  'Title',                  '1st column heading is title' );
755
    is( $report_column_headings[0][1],  'Publisher',              '2nd column heading is publisher' );
756
    is( $report_column_headings[0][2],  'Publisher_ID',           '3rd column heading is publisher ID' );
757
    is( $report_column_headings[0][3],  'Platform',               '4th column heading is platform' );
758
    is( $report_column_headings[0][4],  'DOI',                    '5th column heading is DOI' );
759
    is( $report_column_headings[0][5],  'Proprietary_ID',         '6th column heading is proprietary ID' );
760
    is( $report_column_headings[0][6],  'ISBN',                   '7th column heading is ISBN' );
761
    is( $report_column_headings[0][7],  'Print_ISSN',             '8th column heading is print ISSN' );
762
    is( $report_column_headings[0][8],  'Online_ISSN',            '9th column heading is online ISSN' );
763
    is( $report_column_headings[0][9],  'URI',                    '10th column heading is URI' );
764
    is( $report_column_headings[0][10], 'Data_Type',              '11th column heading is data type' );
765
    is( $report_column_headings[0][11], 'YOP',                    '12th column heading is yop' );
766
    is( $report_column_headings[0][12], 'Access_Type',            '13th column heading is access type' );
767
    is( $report_column_headings[0][13], 'Metric_Type',            '14th column heading is metric type' );
768
    is( $report_column_headings[0][14], 'Reporting_Period_Total', '15th column heading is reporting period total' );
769
770
    # Months column headings
771
    is( $report_column_headings[0][15], 'Jan 2022', '16th column is month column heading' );
772
    is( $report_column_headings[0][16], 'Feb 2022', '17th column another month column heading' );
773
    is( $report_column_headings[0][17], 'Mar 2022', '18th column is the last month column heading' );
774
    is( $report_column_headings[0][18], undef,      '19th column is empty, no more months' );
775
};
776
777
subtest 'TR_B3 _COUNTER_report_body' => sub {
778
779
    plan tests => 49;
780
781
    my @report_body = $sushi_counter_TR_B3->_COUNTER_report_body;
782
783
    # The same title is sequential but for different metric types
784
    is(
785
        $report_body[0][0], 'Title 1',
786
        'first title, different metric type'
787
    );
788
    is(
789
        $report_body[1][0], 'Title 1',
790
        'first title, different metric type'
791
    );
792
    is(
793
        $report_body[2][0], 'Title 1',
794
        'first title, different metric type'
795
    );
796
    is(
797
        $report_body[3][0], 'Title 1',
798
        'first title, different metric type'
799
    );
800
    is(
801
        $report_body[4][0], 'Title 1',
802
        'first title, different metric type'
803
    );
804
    is(
805
        $report_body[5][0], 'Title 1',
806
        'first title, different metric type'
807
    );
808
    is(
809
        $report_body[6][0], 'Title 7',
810
        'second title, different metric type'
811
    );
812
    is(
813
        $report_body[7][0], 'Title 7',
814
        'second title, different metric type'
815
    );
816
    is(
817
        $report_body[8][0], 'Title 7',
818
        'second title, different metric type'
819
    );
820
    is( $report_body[0][10], 'Book',                        '6 rows for 1st title' );
821
    is( $report_body[1][10], 'Book',                        '6 rows for 1st title' );
822
    is( $report_body[2][10], 'Book',                        '6 rows for 1st title' );
823
    is( $report_body[3][10], 'Book',                        '6 rows for 1st title' );
824
    is( $report_body[4][10], 'Book',                        '6 rows for 1st title' );
825
    is( $report_body[5][10], 'Book',                        '6 rows for 1st title' );
826
    is( $report_body[0][11], '2022',                        '1st title, yop' );
827
    is( $report_body[1][11], '2022',                        '1st title, yop' );
828
    is( $report_body[2][11], '2022',                        '1st title,yop' );
829
    is( $report_body[3][11], '2022',                        '1st title, 2nd yop has 6 metric types' );
830
    is( $report_body[4][11], '2022',                        '1st title, 2nd yop has 6 metric types' );
831
    is( $report_body[5][11], '2022',                        '1st title, 2nd yop has 6 metric types' );
832
    is( $report_body[0][12], 'Controlled',                  '6 rows for 1st title' );
833
    is( $report_body[1][12], 'Controlled',                  '6 rows for 1st title' );
834
    is( $report_body[2][12], 'Controlled',                  '6 rows for 1st title' );
835
    is( $report_body[3][12], 'Controlled',                  '6 rows for 1st title' );
836
    is( $report_body[4][12], 'Controlled',                  '6 rows for 1st title' );
837
    is( $report_body[5][12], 'Controlled',                  '6 rows for 1st title' );
838
    is( $report_body[0][13], 'Total_Item_Investigations',   '1st title, metric type' );
839
    is( $report_body[1][13], 'Total_Item_Requests',         '1st title, metric type' );
840
    is( $report_body[2][13], 'Unique_Item_Investigations',  '1st title, metric type' );
841
    is( $report_body[3][13], 'Unique_Item_Requests',        '1st title, metric type' );
842
    is( $report_body[4][13], 'Unique_Title_Investigations', '1st title, metric type' );
843
    is( $report_body[5][13], 'Unique_Title_Requests',       '1st title, metric type' );
844
845
    # The data is in the correct column
846
    is( $report_body[2][0],  'Title 1',                    '1st column is title' );
847
    is( $report_body[2][1],  'Sample Publisher',           '2nd column is publisher' );
848
    is( $report_body[2][2],  '4321432143214321',           '3rd column is publisher ID' );
849
    is( $report_body[2][3],  'Platform 1',                 '4th column is platform' );
850
    is( $report_body[2][4],  '10.9999/xxxxt01',            '5th column is DOI' );
851
    is( $report_body[2][5],  'P1:T01',                     '6th column is proprietary ID' );
852
    is( $report_body[2][6],  '979-8-88888-888-8',          '7th column is ISBN' );
853
    is( $report_body[2][7],  '',                           '8th column is print ISSN' );
854
    is( $report_body[2][8],  '',                           '9th column is online ISSN' );
855
    is( $report_body[2][9],  '',                           '10th column is URI' );
856
    is( $report_body[2][10], 'Book',                       '11th column is data_type' );
857
    is( $report_body[2][11], '2022',                       '12th column is yop' );
858
    is( $report_body[2][12], 'Controlled',                 '12th column is access type' );
859
    is( $report_body[2][13], 'Unique_Item_Investigations', '13th column is metric type' );
860
    is( $report_body[2][14], 2760,                         '14th column is reporting period total' );    #828+935+997
861
862
    # The period total is the sum of all the month columns
863
    my $stats_total = 0;
864
    for ( my $i = 15 ; $i < 18 ; $i++ ) {
865
        $stats_total += $report_body[0][$i];
866
    }
867
    is(
868
        $report_body[0][14], $stats_total,
869
        'Reporting period total matches the sum of all the monthly usage statistics'
870
    );
871
};
872
873
my $sushi_response_file_TR_B2       = dirname(__FILE__) . $test_data_base_dir . "/TR_B2.json";
874
my $sushi_counter_51_response_TR_B2 = decode_json( read_file($sushi_response_file_TR_B2) );
875
my $sushi_counter_TR_B2 = Koha::ERM::EUsage::SushiCounter->new( { response => $sushi_counter_51_response_TR_B2 } );
876
877
subtest 'TR_B2 _COUNTER_report_header' => sub {
878
879
    plan tests => 42;
880
881
    my @report_header = $sushi_counter_TR_B2->_COUNTER_report_header;
882
883
    # Header row #1 - Report_Name
884
    is( $report_header[0][0], 'Report_Name',        '1st row is report name' );
885
    is( $report_header[0][1], 'Book Access Denied', '1st row is report name' );
886
    is( $report_header[0][2], undef,                '1st row is report name' );
887
888
    # Header row #2 - Report_ID
889
    is( $report_header[1][0], 'Report_ID', '2nd row is report name' );
890
    is( $report_header[1][1], 'TR_B2',     '2nd row is report name' );
891
    is( $report_header[1][2], undef,       '2nd row is report name' );
892
893
    # Header row #3 - Release
894
    is( $report_header[2][0], 'Release', '3rd row is counter release' );
895
    is( $report_header[2][1], '5.1',     '3rd row is counter release' );
896
    is( $report_header[2][2], undef,     '3rd row is counter release' );
897
898
    # Header row #4 - Institution_Name
899
    is( $report_header[3][0], 'Institution_Name',   '4th row is institution name' );
900
    is( $report_header[3][1], 'Sample Institution', '4th row is institution name' );
901
    is( $report_header[3][2], undef,                '4th row is institution name' );
902
903
    # Header row #5 - Institution_ID
904
    is( $report_header[4][0], 'Institution_ID',        '5th row is institution id' );
905
    is( $report_header[4][1], 'ISNI:1234123412341234', '5th row is institution id' );
906
    is( $report_header[4][2], undef,                   '5th row is institution id' );
907
908
    # Header row #6 - Metric_Types
909
    is( $report_header[5][0], 'Metric_Types', '6th row is metric types' );
910
    is(
911
        $report_header[5][1],
912
        'Limit_Exceeded; No_License',
913
        '6th row is metric types'
914
    );
915
    is( $report_header[5][2], undef, '6th row is metric types' );
916
917
    # Header row #7 - Report_Filters
918
    is( $report_header[6][0], 'Report_Filters', '7th row is report filters' );
919
    like( $report_header[6][1], qr/Data_Type:Book/,                         '7th row is report filters' );
920
    like( $report_header[6][1], qr/Access_Method:Regular/,                  '7th row is report filters' );
921
    like( $report_header[6][1], qr/Metric_Type:Limit_Exceeded\|No_License/, '7th row is report filters' );
922
    like( $report_header[6][1], qr/Begin_Date:2022-01-01/,                  '7th row is report filters' );
923
    like( $report_header[6][1], qr/End_Date:2022-03-31/,                    '7th row is report filters' );
924
925
    is( $report_header[6][2], undef, '7th row is report filters' );
926
927
    # Header row #8 - Report_Attributes
928
    is( $report_header[7][0], 'Report_Attributes', '8th row is report attributes' );
929
    is( $report_header[7][1], '',                  '8th row is report attributes' );
930
    is( $report_header[7][2], undef,               '8th row is report attributes' );
931
932
    # Header row #9 - Exceptions
933
    is( $report_header[8][0], 'Exceptions', '9th row is exceptions' );
934
    is( $report_header[8][1], '',           '9th row is exceptions' );
935
    is( $report_header[8][2], undef,        '9th row is exceptions' );
936
937
    # Header row #10 - Reporting_Period
938
    is( $report_header[9][0], 'Reporting_Period',                           '10th row is reporting period' );
939
    is( $report_header[9][1], 'Begin_Date=2022-01-01; End_Date=2022-03-31', '10th row is reporting period' );
940
    is( $report_header[9][2], undef,                                        '10th row is reporting period' );
941
942
    # Header row #11 - Created
943
    is( $report_header[10][0], 'Created',              '11th row is created' );
944
    is( $report_header[10][1], '2023-02-15T09:11:12Z', '11th row is created' );
945
    is( $report_header[10][2], undef,                  '11th row is created' );
946
947
    # Header row #12 - Created
948
    is( $report_header[11][0], 'Created_By',       '12th row is created by' );
949
    is( $report_header[11][1], 'Sample Publisher', '12th row is created by' );
950
    is( $report_header[11][2], undef,              '12th row is created by' );
951
952
    # Header row #13 - Registry_Record
953
    is( $report_header[12][0], 'Registry_Record', '13th row is Registry_Record' );
954
955
    # Header row #14 - This needs to be empty
956
    is( $report_header[13][0], '', '14th row is empty' );
957
};
958
959
subtest 'TR_B2 _COUNTER_report_column_headings' => sub {
960
961
    plan tests => 18;
962
963
    my @report_column_headings = $sushi_counter_TR_B2->_COUNTER_report_column_headings;
964
965
    # Standard TR_J4 column headings
966
    is( $report_column_headings[0][0],  'Title',                  '1st column heading is title' );
967
    is( $report_column_headings[0][1],  'Publisher',              '2nd column heading is publisher' );
968
    is( $report_column_headings[0][2],  'Publisher_ID',           '3rd column heading is publisher ID' );
969
    is( $report_column_headings[0][3],  'Platform',               '4th column heading is platform' );
970
    is( $report_column_headings[0][4],  'DOI',                    '5th column heading is DOI' );
971
    is( $report_column_headings[0][5],  'Proprietary_ID',         '6th column heading is proprietary ID' );
972
    is( $report_column_headings[0][6],  'ISBN',                   '7th column heading is ISBN' );
973
    is( $report_column_headings[0][7],  'Print_ISSN',             '8th column heading is print ISSN' );
974
    is( $report_column_headings[0][8],  'Online_ISSN',            '9th column heading is online ISSN' );
975
    is( $report_column_headings[0][9],  'URI',                    '10th column heading is URI' );
976
    is( $report_column_headings[0][10], 'Data_Type',              '11th column heading is data type' );
977
    is( $report_column_headings[0][11], 'YOP',                    '12th column heading is yop' );
978
    is( $report_column_headings[0][12], 'Metric_Type',            '13th column heading is metric type' );
979
    is( $report_column_headings[0][13], 'Reporting_Period_Total', '14th column heading is reporting period total' );
980
981
    # Months column headings
982
    is( $report_column_headings[0][14], 'Jan 2022', '14th column is month column heading' );
983
    is( $report_column_headings[0][15], 'Feb 2022', '15th column is another column heading' );
984
    is( $report_column_headings[0][16], 'Mar 2022', '16th column is the last month column heading' );
985
    is( $report_column_headings[0][17], undef,      '17th column is empty, no more months' );
986
};
987
988
subtest 'TR_B2 _COUNTER_report_body' => sub {
989
990
    plan tests => 19;
991
992
    my @report_body = $sushi_counter_TR_B2->_COUNTER_report_body;
993
994
    # The same title is sequential but for different metric types
995
    is(
996
        $report_body[0][0], 'Title 1',
997
        'same title, different metric type'
998
    );
999
    is(
1000
        $report_body[1][0], 'Title 1',
1001
        'same title, different metric type'
1002
    );
1003
    is( $report_body[0][12], 'Limit_Exceeded', '2 rows for 1st title, metric type' );
1004
    is( $report_body[1][12], 'No_License',     '2 rows for 1st title, metric type' );
1005
1006
    # The data is in the correct column
1007
    is( $report_body[2][0],  'Title 7',           '1st column is title' );
1008
    is( $report_body[2][1],  'Sample Publisher',  '2nd column is publisher' );
1009
    is( $report_body[2][2],  '4321432143214321',  '3rd column heading is publisher ID' );
1010
    is( $report_body[2][3],  'Platform 1',        '4th column is platform' );
1011
    is( $report_body[2][4],  '10.9999/xxxxt07',   '5th column is DOI' );
1012
    is( $report_body[2][5],  'P1:T07',            '6th column is proprietary ID' );
1013
    is( $report_body[2][6],  '979-8-88888-888-9', '7th column is ISBN' );
1014
    is( $report_body[2][7],  '',                  '8th column is print ISSN' );
1015
    is( $report_body[2][8],  '',                  '9th column is online ISSN' );
1016
    is( $report_body[2][9],  '',                  '10th column is URI' );
1017
    is( $report_body[2][10], 'Reference_Work',    '11th column is data type' );
1018
    is( $report_body[2][11], '2019',              '11th column is yop' );
1019
    is( $report_body[2][12], 'Limit_Exceeded',    '12th column is access type' );
1020
    is( $report_body[2][13], 217,                 '13th column is reporting period total' );    #84+84+49
1021
1022
    # The period total is the sum of all the month columns
1023
    my $stats_total = 0;
1024
    for ( my $i = 14 ; $i < 17 ; $i++ ) {
1025
        $stats_total += $report_body[0][$i];
1026
    }
1027
    is(
1028
        $report_body[0][13], $stats_total,
1029
        'Reporting period total matches the sum of all the monthly usage statistics'
1030
    );
1031
};
(-)a/t/db_dependent/data/erm/eusage/COUNTER_5.1/TR_B2.json (+101 lines)
Line 0 Link Here
1
{
2
  "Report_Header": {
3
    "Release": "5.1",
4
    "Report_ID": "TR_B2",
5
    "Report_Name": "Book Access Denied",
6
    "Created": "2023-02-15T09:11:12Z",
7
    "Created_By": "Sample Publisher",
8
    "Institution_ID": {
9
      "ISNI": [
10
        "1234123412341234"
11
      ]
12
    },
13
    "Institution_Name": "Sample Institution",
14
    "Registry_Record": "https://registry.projectcounter.org/platform/99999999-9999-9999-9999-999999999999",
15
    "Report_Filters": {
16
      "Metric_Type": [
17
        "Limit_Exceeded",
18
        "No_License"
19
      ],
20
      "Begin_Date": "2022-01-01",
21
      "End_Date": "2022-03-31",
22
      "Data_Type": [
23
        "Book",
24
        "Reference_Work"
25
      ],
26
      "Access_Method": [
27
        "Regular"
28
      ]
29
    }
30
  },
31
  "Report_Items": [
32
    {
33
      "Title": "Title 1",
34
      "Publisher": "Sample Publisher",
35
      "Publisher_ID": {
36
        "ISNI": [
37
          "4321432143214321"
38
        ]
39
      },
40
      "Platform": "Platform 1",
41
      "Item_ID": {
42
        "DOI": "10.9999/xxxxt01",
43
        "Proprietary": "P1:T01",
44
        "ISBN": "979-8-88888-888-8",
45
        "URI": "https://doi.org/10.9999/xxxxt01"
46
      },
47
      "Attribute_Performance": [
48
        {
49
          "Data_Type": "Book",
50
          "YOP": "2022",
51
          "Performance": {
52
            "Limit_Exceeded": {
53
              "2022-01": 49,
54
              "2022-02": 90,
55
              "2022-03": 40
56
            },
57
            "No_License": {
58
              "2022-01": 50,
59
              "2022-02": 84,
60
              "2022-03": 47
61
            }
62
          }
63
        }
64
      ]
65
    },
66
    {
67
      "Title": "Title 7",
68
      "Publisher": "Sample Publisher",
69
      "Publisher_ID": {
70
        "ISNI": [
71
          "4321432143214321"
72
        ]
73
      },
74
      "Platform": "Platform 1",
75
      "Item_ID": {
76
        "DOI": "10.9999/xxxxt07",
77
        "Proprietary": "P1:T07",
78
        "ISBN": "979-8-88888-888-9",
79
        "URI": "https://doi.org/10.9999/xxxxt07"
80
      },
81
      "Attribute_Performance": [
82
        {
83
          "Data_Type": "Reference_Work",
84
          "YOP": "2019",
85
          "Performance": {
86
            "Limit_Exceeded": {
87
              "2022-01": 84,
88
              "2022-02": 84,
89
              "2022-03": 49
90
            },
91
            "No_License": {
92
              "2022-01": 70,
93
              "2022-02": 74,
94
              "2022-03": 54
95
            }
96
          }
97
        }
98
      ]
99
    }
100
  ]
101
}
(-)a/t/db_dependent/data/erm/eusage/COUNTER_5.1/TR_B3.json (+147 lines)
Line 0 Link Here
1
{
2
  "Report_Header": {
3
    "Release": "5.1",
4
    "Report_ID": "TR_B3",
5
    "Report_Name": "Book Usage by Access Type",
6
    "Created": "2023-02-15T09:11:12Z",
7
    "Created_By": "Sample Publisher",
8
    "Institution_ID": {
9
      "ISNI": [
10
        "1234123412341234"
11
      ]
12
    },
13
    "Institution_Name": "Sample Institution",
14
    "Registry_Record": "https://registry.projectcounter.org/platform/99999999-9999-9999-9999-999999999999",
15
    "Report_Filters": {
16
      "Metric_Type": [
17
        "Total_Item_Investigations",
18
        "Total_Item_Requests",
19
        "Unique_Item_Investigations",
20
        "Unique_Item_Requests",
21
        "Unique_Title_Investigations",
22
        "Unique_Title_Requests"
23
      ],
24
      "Begin_Date": "2022-01-01",
25
      "End_Date": "2022-03-31",
26
      "Data_Type": [
27
        "Book",
28
        "Reference_Work"
29
      ],
30
      "Access_Method": [
31
        "Regular"
32
      ]
33
    }
34
  },
35
  "Report_Items": [
36
    {
37
      "Title": "Title 1",
38
      "Publisher": "Sample Publisher",
39
      "Publisher_ID": {
40
        "ISNI": [
41
          "4321432143214321"
42
        ]
43
      },
44
      "Platform": "Platform 1",
45
      "Item_ID": {
46
        "DOI": "10.9999/xxxxt01",
47
        "Proprietary": "P1:T01",
48
        "ISBN": "979-8-88888-888-8",
49
        "URI": "https://doi.org/10.9999/xxxxt01"
50
      },
51
      "Attribute_Performance": [
52
        {
53
          "Data_Type": "Book",
54
          "YOP": "2022",
55
          "Access_Type": "Controlled",
56
          "Performance": {
57
            "Total_Item_Investigations": {
58
              "2022-01": 1104,
59
              "2022-02": 1246,
60
              "2022-03": 1329
61
            },
62
            "Total_Item_Requests": {
63
              "2022-01": 662,
64
              "2022-02": 748,
65
              "2022-03": 797
66
            },
67
            "Unique_Item_Investigations": {
68
              "2022-01": 828,
69
              "2022-02": 935,
70
              "2022-03": 997
71
            },
72
            "Unique_Item_Requests": {
73
              "2022-01": 497,
74
              "2022-02": 561,
75
              "2022-03": 598
76
            },
77
            "Unique_Title_Investigations": {
78
              "2022-01": 552,
79
              "2022-02": 623,
80
              "2022-03": 665
81
            },
82
            "Unique_Title_Requests": {
83
              "2022-01": 414,
84
              "2022-02": 467,
85
              "2022-03": 499
86
            }
87
          }
88
        }
89
      ]
90
    },
91
    {
92
      "Title": "Title 7",
93
      "Publisher": "Sample Publisher",
94
      "Publisher_ID": {
95
        "ISNI": [
96
          "4321432143214321"
97
        ]
98
      },
99
      "Platform": "Platform 1",
100
      "Item_ID": {
101
        "DOI": "10.9999/xxxxt07",
102
        "Proprietary": "P1:T07",
103
        "ISBN": "979-8-88888-888-9",
104
        "URI": "https://doi.org/10.9999/xxxxt07"
105
      },
106
      "Attribute_Performance": [
107
        {
108
          "Data_Type": "Reference_Work",
109
          "YOP": "2019",
110
          "Access_Type": "Controlled",
111
          "Performance": {
112
            "Total_Item_Investigations": {
113
              "2022-01": 1645,
114
              "2022-02": 1022,
115
              "2022-03": 1106
116
            },
117
            "Total_Item_Requests": {
118
              "2022-01": 987,
119
              "2022-02": 613,
120
              "2022-03": 664
121
            },
122
            "Unique_Item_Investigations": {
123
              "2022-01": 1234,
124
              "2022-02": 767,
125
              "2022-03": 830
126
            },
127
            "Unique_Item_Requests": {
128
              "2022-01": 740,
129
              "2022-02": 460,
130
              "2022-03": 498
131
            },
132
            "Unique_Title_Investigations": {
133
              "2022-01": 301,
134
              "2022-02": 283,
135
              "2022-03": 217
136
            },
137
            "Unique_Title_Requests": {
138
              "2022-01": 226,
139
              "2022-02": 212,
140
              "2022-03": 163
141
            }
142
          }
143
        }
144
      ]
145
    }
146
  ]
147
}
(-)a/t/db_dependent/data/erm/eusage/COUNTER_5.1/TR_J1.json (+104 lines)
Line 0 Link Here
1
{
2
  "Report_Header": {
3
    "Release": "5.1",
4
    "Report_ID": "TR_J1",
5
    "Report_Name": "Journal Requests (Excluding OA_Gold)",
6
    "Created": "2023-08-29T07:11:41Z",
7
    "Created_By": "Test Systems Inc.",
8
    "Institution_ID": {
9
      "Proprietary": [
10
        "TInsti:EALTEST001"
11
      ],
12
      "ISNI": [
13
        "0000000123456789"
14
      ]
15
    },
16
    "Institution_Name": "Test Institution",
17
    "Registry_Record": "https://registry.projectcounter.org/platform/99999999-9999-9999-9999-999999999999",
18
    "Report_Filters": {
19
      "Metric_Type": [
20
        "Total_Item_Requests",
21
        "Unique_Item_Requests"
22
      ],
23
      "Begin_Date": "2021-09-01",
24
      "End_Date": "2022-09-30",
25
      "Data_Type": [
26
        "Journal"
27
      ],
28
      "Access_Type": [
29
        "Controlled"
30
      ],
31
      "Access_Method": [
32
        "Regular"
33
      ],
34
      "Data_Type": [
35
        "Journal"
36
      ]
37
    }
38
  },
39
  "Report_Items": [
40
    {
41
      "Title": "Education and Training",
42
      "Publisher": "Sample Publisher",
43
      "Publisher_ID": {
44
        "ISNI": [
45
          "4321432143214321"
46
        ]
47
      },
48
      "Platform": "Platform 1",
49
      "Item_ID": {
50
        "DOI": "10.9999/xxxxt03",
51
        "Proprietary": "P1:T03",
52
        "Online_ISSN": "1234-4321",
53
        "URI": "https://doi.org/10.9999/xxxxt03"
54
      },
55
      "Attribute_Performance": [
56
        {
57
          "Performance": {
58
            "Total_Item_Requests": {
59
              "2022-01": 526,
60
              "2022-02": 866,
61
              "2022-03": 852
62
            },
63
            "Unique_Item_Requests": {
64
              "2022-01": 226,
65
              "2022-02": 372,
66
              "2022-03": 366
67
            }
68
          }
69
        }
70
      ]
71
    },
72
    {
73
      "Title": "Test Journal",
74
      "Publisher": "Test Publisher",
75
      "Publisher_ID": {
76
        "ISNI": [
77
          "0000000123456789"
78
        ]
79
      },
80
      "Platform": "Unit Test Library",
81
      "Item_ID": {
82
        "DOI": "10.1002/(ISSN)1111-2222",
83
        "Proprietary": "TInsti:ABC1",
84
        "Online_ISSN": "5555-6666",
85
        "URI": "https://doi.org/10.9999/xxxxt03",
86
        "Print_ISSN": "7777-8888"
87
      },
88
      "Attribute_Performance": [
89
        {
90
          "Performance": {
91
            "Total_Item_Requests": {
92
              "2022-01": 1,
93
              "2022-06": 1
94
            },
95
            "Unique_Item_Requests": {
96
              "2022-01": 1,
97
              "2022-06": 1
98
            }
99
          }
100
        }
101
      ]
102
    }
103
  ]
104
}
(-)a/t/db_dependent/data/erm/eusage/COUNTER_5.1/TR_J2.json (+96 lines)
Line 0 Link Here
1
{
2
  "Report_Header": {
3
    "Release": "5.1",
4
    "Report_ID": "TR_J2",
5
    "Report_Name": "Journal Access Denied",
6
    "Created": "2023-02-15T09:11:12Z",
7
    "Created_By": "Sample Publisher",
8
    "Institution_ID": {
9
      "ISNI": [
10
        "1234123412341234"
11
      ]
12
    },
13
    "Institution_Name": "Sample Institution",
14
    "Registry_Record": "https://registry.projectcounter.org/platform/99999999-9999-9999-9999-999999999999",
15
    "Report_Filters": {
16
      "Metric_Type": [
17
        "Limit_Exceeded",
18
        "No_License"
19
      ],
20
      "Begin_Date": "2022-01-01",
21
      "End_Date": "2022-03-31",
22
      "Data_Type": [
23
        "Journal"
24
      ],
25
      "Access_Method": [
26
        "Regular"
27
      ]
28
    }
29
  },
30
  "Report_Items": [
31
    {
32
      "Title": "Title 3",
33
      "Publisher": "Sample Publisher",
34
      "Publisher_ID": {
35
        "ISNI": [
36
          "4321432143214321"
37
        ]
38
      },
39
      "Platform": "Platform 1",
40
      "Item_ID": {
41
        "DOI": "10.9999/xxxxt03",
42
        "Proprietary": "P1:T03",
43
        "Online_ISSN": "1234-4321",
44
        "URI": "https://doi.org/10.9999/xxxxt03"
45
      },
46
      "Attribute_Performance": [
47
        {
48
          "Performance": {
49
            "Limit_Exceeded": {
50
              "2022-01": 174,
51
              "2022-02": 176,
52
              "2022-03": 90
53
            },
54
            "No_License": {
55
              "2022-01": 96,
56
              "2022-02": 160,
57
              "2022-03": 74
58
            }
59
          }
60
        }
61
      ]
62
    },
63
    {
64
      "Title": "Another title",
65
      "Publisher": "Another publisher",
66
      "Publisher_ID": {
67
        "ISNI": [
68
          "4321432143214321"
69
        ]
70
      },
71
      "Platform": "Platform 1",
72
      "Item_ID": {
73
        "DOI": "10.9999/xxxxt03",
74
        "Proprietary": "P1:T03",
75
        "Online_ISSN": "1234-4321",
76
        "URI": "https://doi.org/10.9999/xxxxt03"
77
      },
78
      "Attribute_Performance": [
79
        {
80
          "Performance": {
81
            "Limit_Exceeded": {
82
              "2022-01": 222,
83
              "2022-02": 111,
84
              "2022-03": 55
85
            },
86
            "No_License": {
87
              "2022-01": 11,
88
              "2022-02": 22,
89
              "2022-03": 33
90
            }
91
          }
92
        }
93
      ]
94
    }
95
  ]
96
}
(-)a/t/db_dependent/data/erm/eusage/COUNTER_5.1/TR_J3.json (+170 lines)
Line 0 Link Here
1
{
2
  "Report_Header": {
3
    "Release": "5.1",
4
    "Report_ID": "TR_J3",
5
    "Report_Name": "Journal Usage by Access Type",
6
    "Created": "2023-02-15T09:11:12Z",
7
    "Created_By": "Sample Publisher",
8
    "Institution_ID": {
9
      "ISNI": [
10
        "1234123412341234"
11
      ]
12
    },
13
    "Institution_Name": "Sample Institution",
14
    "Registry_Record": "https://registry.projectcounter.org/platform/99999999-9999-9999-9999-999999999999",
15
    "Report_Filters": {
16
      "Metric_Type": [
17
        "Total_Item_Investigations",
18
        "Total_Item_Requests",
19
        "Unique_Item_Investigations",
20
        "Unique_Item_Requests"
21
      ],
22
      "Begin_Date": "2022-01-01",
23
      "End_Date": "2022-03-31",
24
      "Data_Type": [
25
        "Journal"
26
      ],
27
      "Access_Method": [
28
        "Regular"
29
      ]
30
    }
31
  },
32
  "Report_Items": [
33
    {
34
      "Title": "Title 3",
35
      "Publisher": "Sample Publisher",
36
      "Publisher_ID": {
37
        "ISNI": [
38
          "4321432143214321"
39
        ]
40
      },
41
      "Platform": "Platform 1",
42
      "Item_ID": {
43
        "DOI": "10.9999/xxxxt03",
44
        "Proprietary": "P1:T03",
45
        "Online_ISSN": "1234-4321",
46
        "URI": "https://doi.org/10.9999/xxxxt03"
47
      },
48
      "Attribute_Performance": [
49
        {
50
          "Access_Type": "Controlled",
51
          "Performance": {
52
            "Total_Item_Investigations": {
53
              "2022-01": 500,
54
              "2022-02": 824,
55
              "2022-03": 812
56
            },
57
            "Total_Item_Requests": {
58
              "2022-01": 300,
59
              "2022-02": 494,
60
              "2022-03": 486
61
            },
62
            "Unique_Item_Investigations": {
63
              "2022-01": 376,
64
              "2022-02": 618,
65
              "2022-03": 608
66
            },
67
            "Unique_Item_Requests": {
68
              "2022-01": 226,
69
              "2022-02": 372,
70
              "2022-03": 366
71
            }
72
          }
73
        },
74
        {
75
          "Access_Type": "Open",
76
          "Performance": {
77
            "Total_Item_Investigations": {
78
              "2022-01": 1504,
79
              "2022-02": 2476,
80
              "2022-03": 2434
81
            },
82
            "Total_Item_Requests": {
83
              "2022-01": 902,
84
              "2022-02": 1486,
85
              "2022-03": 1462
86
            },
87
            "Unique_Item_Investigations": {
88
              "2022-01": 1128,
89
              "2022-02": 1858,
90
              "2022-03": 1826
91
            },
92
            "Unique_Item_Requests": {
93
              "2022-01": 676,
94
              "2022-02": 1114,
95
              "2022-03": 1096
96
            }
97
          }
98
        }
99
      ]
100
    },
101
    {
102
      "Title": "Title 4",
103
      "Publisher": "Sample Publisher",
104
      "Publisher_ID": {
105
        "ISNI": [
106
          "4321432143214321"
107
        ]
108
      },
109
      "Platform": "Platform 1",
110
      "Item_ID": {
111
        "DOI": "10.9999",
112
        "Proprietary": "P1:T03",
113
        "Online_ISSN": "1234-4321",
114
        "URI": "https://doi.org/10.9999"
115
      },
116
      "Attribute_Performance": [
117
        {
118
          "Access_Type": "Controlled",
119
          "Performance": {
120
            "Total_Item_Investigations": {
121
              "2022-01": 3,
122
              "2022-02": 4,
123
              "2022-03": 9
124
            },
125
            "Total_Item_Requests": {
126
              "2022-01": 55,
127
              "2022-02": 44,
128
              "2022-03": 33
129
            },
130
            "Unique_Item_Investigations": {
131
              "2022-01": 88,
132
              "2022-02": 55,
133
              "2022-03": 77
134
            },
135
            "Unique_Item_Requests": {
136
              "2022-01": 22,
137
              "2022-02": 33,
138
              "2022-03": 44
139
            }
140
          }
141
        },
142
        {
143
          "Access_Type": "Open",
144
          "Performance": {
145
            "Total_Item_Investigations": {
146
              "2022-01": 55,
147
              "2022-02": 76,
148
              "2022-03": 12
149
            },
150
            "Total_Item_Requests": {
151
              "2022-01": 65,
152
              "2022-02": 34,
153
              "2022-03": 87
154
            },
155
            "Unique_Item_Investigations": {
156
              "2022-01": 12,
157
              "2022-02": 66,
158
              "2022-03": 88
159
            },
160
            "Unique_Item_Requests": {
161
              "2022-01": 45,
162
              "2022-02": 23,
163
              "2022-03": 76
164
            }
165
          }
166
        }
167
      ]
168
    }
169
  ]
170
}
(-)a/t/db_dependent/data/erm/eusage/COUNTER_5.1/TR_J4.json (-1 / +83 lines)
Line 0 Link Here
0
- 
1
{
2
  "Report_Header": {
3
    "Release": "5.1",
4
    "Report_ID": "TR_J4",
5
    "Report_Name": "Journal Requests by YOP (Controlled)",
6
    "Created": "2023-02-15T09:11:12Z",
7
    "Created_By": "Sample Publisher",
8
    "Institution_ID": {
9
      "ISNI": [
10
        "1234123412341234"
11
      ]
12
    },
13
    "Institution_Name": "Sample Institution",
14
    "Registry_Record": "https://registry.projectcounter.org/platform/99999999-9999-9999-9999-999999999999",
15
    "Report_Filters": {
16
      "Metric_Type": [
17
        "Total_Item_Requests",
18
        "Unique_Item_Requests"
19
      ],
20
      "Begin_Date": "2022-01-01",
21
      "End_Date": "2022-03-31",
22
      "Data_Type": [
23
        "Journal"
24
      ],
25
      "Access_Type": [
26
        "Controlled"
27
      ],
28
      "Access_Method": [
29
        "Regular"
30
      ]
31
    }
32
  },
33
  "Report_Items": [
34
    {
35
      "Title": "Title 3",
36
      "Publisher": "Sample Publisher",
37
      "Publisher_ID": {
38
        "ISNI": [
39
          "4321432143214321"
40
        ]
41
      },
42
      "Platform": "Platform 1",
43
      "Item_ID": {
44
        "DOI": "10.9999/xxxxt03",
45
        "Proprietary": "P1:T03",
46
        "Online_ISSN": "1234-4321",
47
        "URI": "https://doi.org/10.9999/xxxxt03"
48
      },
49
      "Attribute_Performance": [
50
        {
51
          "YOP": "2022",
52
          "Performance": {
53
            "Total_Item_Requests": {
54
              "2022-01": 150,
55
              "2022-02": 247,
56
              "2022-03": 243
57
            },
58
            "Unique_Item_Requests": {
59
              "2022-01": 113,
60
              "2022-02": 186,
61
              "2022-03": 183
62
            }
63
          }
64
        },
65
        {
66
          "YOP": "2021",
67
          "Performance": {
68
            "Total_Item_Requests": {
69
              "2022-01": 150,
70
              "2022-02": 247,
71
              "2022-03": 243
72
            },
73
            "Unique_Item_Requests": {
74
              "2022-01": 113,
75
              "2022-02": 186,
76
              "2022-03": 183
77
            }
78
          }
79
        }
80
      ]
81
    }
82
  ]
83
}

Return to bug 39345