Skip to content

Commit

Permalink
Limit implementation for sub list_scheduled_ajax
Browse files Browse the repository at this point in the history
  • Loading branch information
r-richardson committed Nov 4, 2022
1 parent 8dcd4bf commit b054c4e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/OpenQA/WebAPI/Controller/Test.pm
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ sub list_running_ajax {

sub list_scheduled_ajax {
my ($self) = @_;
my $limits = OpenQA::App->singleton->config->{misc_limits};
my $limit = min($limits->{generic_max_limit}, $self->param('limit') // $limits->{generic_default_limit});

my $scheduled = $self->schema->resultset('Jobs')->complex_query(
state => [OpenQA::Jobs::Constants::PRE_EXECUTION_STATES],
Expand All @@ -183,7 +185,9 @@ sub list_scheduled_ajax {
);

my @scheduled;
while (my $job = $scheduled->next) {
my $i = 0;
while (my $job = $scheduled->next and $i < $limit) {
$i++;
my $job_id = $job->id;
push(
@scheduled,
Expand Down

0 comments on commit b054c4e

Please sign in to comment.