Allow a per-jobset check interval

This allows checking a jobset (say) at most once a day.  It's also
possible to disable polling by setting the interval to 0.  This is
useful for jobsets that use push notification or are manually
evaluated.
This commit is contained in:
Eelco Dolstra 2013-05-02 17:51:38 +02:00
parent edaeb892e7
commit e96916533f
8 changed files with 33 additions and 7 deletions

View file

@ -206,7 +206,8 @@ sub updateJobset {
, enableemail => defined $c->request->params->{enableemail} ? 1 : 0 , enableemail => defined $c->request->params->{enableemail} ? 1 : 0
, emailoverride => trim($c->request->params->{emailoverride}) || "" , emailoverride => trim($c->request->params->{emailoverride}) || ""
, hidden => defined $c->request->params->{visible} ? 0 : 1 , hidden => defined $c->request->params->{visible} ? 0 : 1
, keepnr => trim($c->request->params->{keepnr}) || 3 , keepnr => int(trim($c->request->params->{keepnr})) || 3
, checkinterval => int(trim($c->request->params->{checkinterval}))
, triggertime => $jobset->triggertime // time() , triggertime => $jobset->triggertime // time()
}); });

View file

@ -100,6 +100,12 @@ __PACKAGE__->table("Jobsets");
default_value: 3 default_value: 3
is_nullable: 0 is_nullable: 0
=head2 checkinterval
data_type: 'integer'
default_value: 300
is_nullable: 0
=cut =cut
__PACKAGE__->add_columns( __PACKAGE__->add_columns(
@ -131,6 +137,8 @@ __PACKAGE__->add_columns(
{ data_type => "text", is_nullable => 0 }, { data_type => "text", is_nullable => 0 },
"keepnr", "keepnr",
{ data_type => "integer", default_value => 3, is_nullable => 0 }, { data_type => "integer", default_value => 3, is_nullable => 0 },
"checkinterval",
{ data_type => "integer", default_value => 300, is_nullable => 0 },
); );
=head1 PRIMARY KEY =head1 PRIMARY KEY
@ -252,7 +260,7 @@ __PACKAGE__->belongs_to(
); );
# Created by DBIx::Class::Schema::Loader v0.07033 @ 2013-02-25 19:10:12 # Created by DBIx::Class::Schema::Loader v0.07033 @ 2013-05-02 14:50:55
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:SvBgR0iH9NjVH4jvBATYPA # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:q4amPCWRoWMThnRa/n/y1w
1; 1;

View file

@ -83,6 +83,17 @@
</div> </div>
</div> </div>
<div class="control-group">
<label class="control-label">Check interval</label>
<div class="controls">
<div class="input-append">
<input type="number" class="span3" name="checkinterval" [% HTML.attributes(value => jobset.checkinterval) %]></input>
<span class="add-on">sec</span>
</div>
<span class="help-inline">(0 to disable polling)</span>
</div>
</div>
<div class="control-group"> <div class="control-group">
<div class="controls"> <div class="controls">
<label class="checkbox"> <label class="checkbox">

View file

@ -120,6 +120,10 @@
<th>Enabled:</th> <th>Enabled:</th>
<td>[% jobset.enabled ? "Yes" : "No" %]</td> <td>[% jobset.enabled ? "Yes" : "No" %]</td>
</tr> </tr>
<tr>
<th>Check interval:</th>
<td>[% jobset.checkinterval || "<em>disabled</em>" %]</td>
</tr>
<tr> <tr>
<th>Enable email notification:</th> <th>Enable email notification:</th>
<td>[% jobset.enableemail ? "Yes" : "No" %]</td> <td>[% jobset.enableemail ? "Yes" : "No" %]</td>

View file

@ -268,11 +268,12 @@ sub checkSomeJobset {
{ join => 'project', order_by => [ 'triggertime' ], rows => 1 }); { join => 'project', order_by => [ 'triggertime' ], rows => 1 });
# Otherwise, check the jobset that hasn't been checked for the # Otherwise, check the jobset that hasn't been checked for the
# longest time (but don't check more often than the minimal check # longest time (but don't check more often than the jobset's
# interval). # minimal check interval).
($jobset) = $db->resultset('Jobsets')->search( ($jobset) = $db->resultset('Jobsets')->search(
{ 'project.enabled' => 1, 'me.enabled' => 1, { 'project.enabled' => 1, 'me.enabled' => 1,
, -or => [ 'lastcheckedtime' => undef, 'lastcheckedtime' => { '<', time() - $minCheckInterval } ] }, , 'checkinterval' => { '!=', 0 }
, -or => [ 'lastcheckedtime' => undef, 'lastcheckedtime' => { '<', \ (time() . " - me.checkinterval") } ] },
{ join => 'project', order_by => [ 'lastcheckedtime nulls first' ], rows => 1 }) { join => 'project', order_by => [ 'lastcheckedtime nulls first' ], rows => 1 })
unless defined $jobset; unless defined $jobset;

View file

@ -60,6 +60,7 @@ create table Jobsets (
hidden integer not null default 0, hidden integer not null default 0,
emailOverride text not null, emailOverride text not null,
keepnr integer not null default 3, keepnr integer not null default 3,
checkInterval integer not null default 300, -- minimum time in seconds between polls (0 = disable polling)
primary key (project, name), primary key (project, name),
foreign key (project) references Projects(name) on delete cascade on update cascade foreign key (project) references Projects(name) on delete cascade on update cascade
#ifdef SQLITE #ifdef SQLITE

View file

@ -1,2 +1 @@
create index IndexBuildOutputsOnPath on BuildOutputs(path); create index IndexBuildOutputsOnPath on BuildOutputs(path);

1
src/sql/upgrade-13.sql Normal file
View file

@ -0,0 +1 @@
alter table Jobsets add column checkInterval integer not null default 300;