Bug 41062: Add an option to erm_run_harvester.pl to specify provider IDs

This patch adds a new option to define the providers in cronjob erm_run_harvester.pl
that are used to run the SUSHI harvesting for COUNTER Reports in the ERM module.
Use parameter --provider-id or -p
The parameter provider_id is repeatable.
If the parameter for provider_id is not used all active providers will be harvested (as before).
The script will check if these providers are active (as before).

Script to run on ktd: perl misc/cronjobs/erm_run_harvester.pl --begin-date 2025-09-01 --end-date 2025-09-30

To test:
- Run the script and make sure that all active providers are harvested.
- Apply patch.
- Run the script with only one provider-id.
- Run the script with two provider-ids by using -p 1 -p 2
- Run the script without the parameter.
- Make sure that in all cases only active providers are harvested.
- Sign off :-).

Sponsored-by: Karlsruhe Institute of Technology (KIT)
Signed-off-by: Jan Kissig <bibliothek@th-wildau.de>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 43d32f77d6)
Signed-off-by: Jacob O'Mara <Jacob.omara@openfifth.co.uk>
This commit is contained in:
Raphael Straub 2025-10-20 13:49:15 +00:00 committed by Jacob O'Mara
parent 8f2e2d705e
commit f358d85bf1
No known key found for this signature in database
1 changed files with 27 additions and 14 deletions

View File

@ -38,7 +38,7 @@ erm_run_harvester.pl This script will run the SUSHI harvesting for usage data pr
erm_run_harvester.pl
--begin-date <YYYY-MM-DD>
[ --dry-run ][ --debug ][ --end-date <YYYY-MM-DD> ]
[ --dry-run ][ --debug ][ --end-date <YYYY-MM-DD> ][ -p|--provider-id <id> ... ]
Options:
--help brief help message
@ -47,6 +47,7 @@ erm_run_harvester.pl
--dry-run test run only, do not harvest data
--begin-date <YYYY-MM-DD> date to harvest from
--end-date <YYYY-MM-DD> date to harvest until, defaults to today if not set
-p|--provider-id <id> ... harvest only given providers
=head1 OPTIONS
@ -72,6 +73,10 @@ Date from which to harvest, previously harvested data will be ignored
Date to harvest until, defaults to today if not set
=item B<-p|--provider-id ...>
Provider IDs that should be harvested; harvest all active providers if not set
=item B<--dry-run>
Test run only, do not harvest
@ -95,6 +100,8 @@ C<erm_run_harvester.pl --begin-date 2000-01-01> - Harvest from the given date un
C<erm_run_harvester.pl --begin-date 2000-01-01 --end-date 2024-01-01> - Harvest from the given date until the end date
C<erm_run_harvester.pl --begin-date 2000-01-01 --provider-id 1 --provider-id 3> - Harvest from the given date until today, but only the given providers
C<erm_run_harvester.pl --begin-date 2000-01-01 --end-date 2024-01-01 --debug --dry-run> - Dry run, with debuig information
=cut
@ -103,26 +110,32 @@ my $command_line_options = join( " ", @ARGV );
cronlogaction( { info => $command_line_options } );
# Command line option values
my $help = 0;
my $man = 0;
my $begin_date = 0;
my $end_date = 0;
my $dry_run = 0;
my $debug = 0;
my $help = 0;
my $man = 0;
my $begin_date = 0;
my $end_date = 0;
my @provider_ids = ();
my $dry_run = 0;
my $debug = 0;
my $options = GetOptions(
'h|help' => \$help,
'm|man' => \$man,
'begin-date=s' => \$begin_date,
'end-date=s' => \$end_date,
'dry-run' => \$dry_run,
'debug' => \$debug
'h|help' => \$help,
'm|man' => \$man,
'begin-date=s' => \$begin_date,
'end-date=s' => \$end_date,
'p|provider-id:s' => \@provider_ids,
'dry-run' => \$dry_run,
'debug' => \$debug
);
pod2usage(1) if $help;
pod2usage( -verbose => 2 ) if $man;
my $udproviders = Koha::ERM::EUsage::UsageDataProviders->search( { active => 1 } );
my %search_condition = ( active => 1 );
if ( scalar @provider_ids ) {
$search_condition{erm_usage_data_provider_id} = { -in => \@provider_ids };
}
my $udproviders = Koha::ERM::EUsage::UsageDataProviders->search( \%search_condition );
unless ( scalar @{ $udproviders->as_list() } ) {
die "ERROR: No usage data providers found.";
}