From 704dd412aa247f38ac09b07243e7ac15fd541b67 Mon Sep 17 00:00:00 2001 From: Raphael Straub Date: Mon, 20 Oct 2025 13:49:15 +0000 Subject: [PATCH] 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). 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) --- misc/cronjobs/erm_run_harvester.pl | 41 ++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/misc/cronjobs/erm_run_harvester.pl b/misc/cronjobs/erm_run_harvester.pl index f426b81869..8f28e59547 100755 --- a/misc/cronjobs/erm_run_harvester.pl +++ b/misc/cronjobs/erm_run_harvester.pl @@ -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 - [ --dry-run ][ --debug ][ --end-date ] + [ --dry-run ][ --debug ][ --end-date ][ -p|--provider-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 date to harvest from --end-date date to harvest until, defaults to today if not set + -p|--provider-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 - Harvest from the given date un C - Harvest from the given date until the end date +C - Harvest from the given date until today, but only the given providers + C - 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."; } -- 2.39.5