diff --git a/reports/guided_reports.pl b/reports/guided_reports.pl index 2a4132b7fa..b92f92750b 100755 --- a/reports/guided_reports.pl +++ b/reports/guided_reports.pl @@ -885,42 +885,6 @@ if ( $op eq 'run' ) { my $template_code = $input->param('template_code'); my $want_full_chart = $input->param('want_full_chart') || 0; - # Determine if the user is running this report too many times - my @duplicate_running_report_ids; - my $duplicate_running_reports_per_user_limit = C4::Context->config('duplicate_running_reports_per_user_limit'); - if ( $duplicate_running_reports_per_user_limit && C4::Context->userenv ) { - my $user_id = C4::Context->userenv ? C4::Context->userenv->{number} : undef; - @duplicate_running_report_ids = Koha::Reports->running( { report_id => $report_id, user_id => $user_id } ); - } - my $duplicate_running_reports_per_user_limit_exceeded = - $duplicate_running_reports_per_user_limit - ? scalar(@duplicate_running_report_ids) >= $duplicate_running_reports_per_user_limit - : 0; - - # Determine if the user is running too many reports in total - my @total_running_for_user_report_ids; - my $total_running_reports_per_user_limit = C4::Context->config('total_running_reports_per_user_limit'); - if ( $total_running_reports_per_user_limit && C4::Context->userenv ) { - my $user_id = C4::Context->userenv ? C4::Context->userenv->{number} : undef; - @total_running_for_user_report_ids = Koha::Reports->running( { user_id => $user_id } ); - } - my $total_running_reports_per_user_limit_exceeded = - $total_running_reports_per_user_limit - ? scalar(@total_running_for_user_report_ids) >= $total_running_reports_per_user_limit - : 0; - - # Determine if the Koha instance is running too many reports in total - my @total_running_for_instance_report_ids; - my $total_running_reports_per_instance_limit = C4::Context->config('total_running_reports_per_instance_limit'); - if ( $total_running_reports_per_instance_limit && C4::Context->userenv ) { - my $instance_id = C4::Context->userenv ? C4::Context->userenv->{number} : undef; - @total_running_for_instance_report_ids = Koha::Reports->running(); - } - my $total_running_reports_per_instance_limit_exceeded = - $total_running_reports_per_instance_limit - ? scalar(@total_running_for_instance_report_ids) >= $total_running_reports_per_instance_limit - : 0; - # offset algorithm if ( $input->param('page') ) { $offset = ( $input->param('page') - 1 ) * $limit; @@ -1106,33 +1070,6 @@ if ( $op eq 'run' ) { 'id' => $report_id, 'template_code' => $template_code, ); - } elsif ( $duplicate_running_reports_per_user_limit_exceeded - || $total_running_reports_per_user_limit_exceeded - || $total_running_reports_per_instance_limit_exceeded ) - { - $template->param( - 'sql' => $sql, - 'original_sql' => $original_sql, - 'id' => $report_id, - 'execute' => 1, - 'name' => $name, - 'notes' => $notes, - 'errors' => [ - $duplicate_running_reports_per_user_limit_exceeded - ? { duplicate_running_report_ids => \@duplicate_running_report_ids } - : (), - $total_running_reports_per_user_limit_exceeded - ? { total_running_reports_per_user_limit_exceeded => \@total_running_for_user_report_ids } - : (), - $total_running_reports_per_instance_limit_exceeded - ? { - total_running_reports_per_instance_limit_exceeded => \@total_running_for_instance_report_ids - } - : (), - ], - 'sql_params' => \@sql_params, - 'param_names' => \@param_names, - ); } else { my ( $sql, $header_types ); eval { ( $sql, $header_types ) = $report->prep_report( \@param_names, \@sql_params ); }; @@ -1142,6 +1079,8 @@ if ( $op eq 'run' ) { $error_key = 'duplicate_running_report'; } elsif ( ref($e) eq 'Koha::Exceptions::Report::TotalRunning' ) { $error_key = 'total_running_reports_limit_exceeded'; + } elsif ( ref($e) eq 'Koha::Exceptions::Report::InstanceTotalRunning' ) { + $error_key = 'total_running_reports_per_instance_limit_exceeded'; } if ($error_key) { $template->param(