[#168] Jobs requested via web UI are treated as high priority

This commit is contained in:
Oliver Gorwits
2014-11-14 22:20:10 +00:00
parent 445d26bb31
commit 87a09b0973
2 changed files with 22 additions and 6 deletions

View File

@@ -5,6 +5,7 @@
* [#161] Updated IOS-XR SSHCollector
* [#165] Mention system clock in docs
* [#164] Workers should restart periodically
* [#168] Jobs requested via web UI are treated as high priority
[BUG FIXES]

View File

@@ -25,14 +25,14 @@ our @EXPORT_OK = qw/
/;
our %EXPORT_TAGS = ( all => \@EXPORT_OK );
sub jq_getsome {
my ($num_slots, $prio) = @_;
sub _getsome {
my ($num_slots, $where) = @_;
return () if ((!defined $num_slots) or ($num_slots < 1));
$prio ||= 'normal';
return () if ((!defined $where) or (ref {} ne ref $where));
my $rs = schema('netdisco')->resultset('Admin')
->search(
{status => 'queued', action => { -in => setting('job_prio')->{$prio} } },
{ status => 'queued', %$where },
{ order_by => 'random()', rows => $num_slots },
);
@@ -43,7 +43,22 @@ sub jq_getsome {
return @returned;
}
sub jq_getsomep { return jq_getsome(shift, 'high') }
sub jq_getsome {
return _getsome(shift,
{ action => { -in => setting('job_prio')->{'normal'} } }
);
}
sub jq_getsomep {
return _getsome(shift, {
-or => [{
username => { '!=' => undef },
action => { -in => setting('job_prio')->{'normal'} },
},{
action => { -in => setting('job_prio')->{'high'} },
}],
});
}
sub jq_locked {
my $fqdn = hostfqdn || 'localhost';