Bug 41920: Move total_running_reports_per_instance_limit to Koha/Reports.pm

Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
This commit is contained in:
Lucas Gass 2026-09-10 15:06:44 +00:00 committed by Pedro Amorim
parent 7ba7bbab7d
commit ada73c317c
No known key found for this signature in database
GPG Key ID: 06B75BA7F3894D55
3 changed files with 14 additions and 1 deletions

View File

@ -14,6 +14,11 @@ use Exception::Class (
description => "The configured per-user limit on total simultaneous report runs has been reached",
fields => [ 'user_id', 'limit' ],
},
'Koha::Exceptions::Report::InstanceTotalRunning' => {
isa => 'Koha::Exceptions::Report',
description => "The configured instance-wide limit on total simultaneous report runs has been reached",
fields => ['limit'],
}
);
1;

View File

@ -283,6 +283,14 @@ sub prep_report {
}
}
my $instance_limit = C4::Context->config('total_running_reports_per_instance_limit');
if ($instance_limit) {
my $running = Koha::Reports->running();
if ( $running->count >= $instance_limit ) {
Koha::Exceptions::Report::InstanceTotalRunning->throw( limit => $instance_limit );
}
}
$sql .= " /* { saved_sql.id: $report_id } { user_id: $user_id } */";
return $sql, $headers;

View File

@ -104,7 +104,7 @@ sub running {
}
my $rs = $class->search( { id => { -in => [ keys %report_ids ] } } );
return wantarray ? $rs->as_list : $rs;
return $class->search( { id => { -in => [ keys %report_ids ] } } );
}
=head3 _processlist_rows