Let Builds.timestamp refer to the time the build was added

Previously, for scheduled builds, "timestamp" contained the time the
build was added to the queue, while for finished builds, it was the
time the build finished.  Now it's always the former.
This commit is contained in:
Eelco Dolstra
2013-05-23 10:45:49 -04:00
parent e09622eb29
commit 57b2bb0674
15 changed files with 31 additions and 30 deletions

View File

@ -66,7 +66,7 @@ sub all : Chained('get_builds') PathPart {
$c->stash->{builds} = [ $c->stash->{allBuilds}->search(
{ finished => 1 },
{ order_by => "timestamp DESC"
{ order_by => "stoptime DESC"
, columns => [@buildListColumns]
, rows => $resultsPerPage
, page => $page }) ];
@ -97,7 +97,7 @@ sub latest : Chained('get_builds') PathPart('latest') {
my ($self, $c, @rest) = @_;
my ($latest) = $c->stash->{allBuilds}->search(
{finished => 1, buildstatus => 0}, {order_by => ["isCurrent DESC", "timestamp DESC"]});
{finished => 1, buildstatus => 0}, {order_by => ["id DESC"]});
notFound($c, "There is no successful build to redirect to.") unless defined $latest;
@ -112,7 +112,7 @@ sub latest_for : Chained('get_builds') PathPart('latest-for') {
notFound($c, "You need to specify a platform type in the URL.") unless defined $system;
my ($latest) = $c->stash->{allBuilds}->search(
{finished => 1, buildstatus => 0, system => $system}, {order_by => ["isCurrent DESC", "timestamp DESC"]});
{finished => 1, buildstatus => 0, system => $system}, {order_by => ["id DESC"]});
notFound($c, "There is no successful build for platform `$system' to redirect to.") unless defined $latest;

View File

@ -90,7 +90,7 @@ sub latestbuilds : Chained('api') PathPart('latestbuilds') Args(0) {
$filter->{job} = $job if !$job eq "";
$filter->{system} = $system if !$system eq "";
my @latest = $c->model('DB::Builds')->search($filter, {rows => $nr, order_by => ["timestamp DESC"] });
my @latest = $c->model('DB::Builds')->search($filter, {rows => $nr, order_by => ["id DESC"] });
my @list;
push @list, buildToHash($_) foreach @latest;
@ -142,7 +142,7 @@ sub queue : Chained('api') PathPart('queue') Args(0) {
my $nr = $c->request->params->{nr};
error($c, "Parameter not defined!") if !defined $nr;
my @builds = $c->model('DB::Builds')->search({finished => 0}, {rows => $nr, order_by => ["busy DESC", "priority DESC", "timestamp"]});
my @builds = $c->model('DB::Builds')->search({finished => 0}, {rows => $nr, order_by => ["busy DESC", "priority DESC", "id"]});
my @list;
push @list, buildToHash($_) foreach @builds;

View File

@ -34,7 +34,8 @@ sub machines : Chained('admin') PathPart('machines') Args(0) {
sub clear_queue_non_current : Chained('admin') PathPart('clear-queue-non-current') Args(0) {
my ($self, $c) = @_;
$c->model('DB::Builds')->search({finished => 0, iscurrent => 0, busy => 0})->update({ finished => 1, buildstatus => 4, timestamp => time});
my $time = time();
$c->model('DB::Builds')->search({finished => 0, iscurrent => 0, busy => 0})->update({ finished => 1, buildstatus => 4, starttime => $time, stoptime => $time });
$c->res->redirect($c->request->referer // "/admin");
}

View File

@ -216,7 +216,7 @@ sub download : Chained('build') PathPart {
notFound($c, "Path $path is a directory.") if -d $path;
$c->serve_static_file($path);
$c->response->headers->last_modified($c->stash->{build}->timestamp);
$c->response->headers->last_modified($c->stash->{build}->stoptime);
}
@ -423,9 +423,12 @@ sub cancel : Chained('build') PathPart Args(0) {
# builds as well, but we would have to send a signal or
# something to the build process.
my $time = time();
$build->update(
{ finished => 1, busy => 0, timestamp => time
{ finished => 1, busy => 0
, iscachedbuild => 0, buildstatus => 4 # = cancelled
, starttime => $time
, stoptime => $time
});
});

View File

@ -25,13 +25,13 @@ sub overview : Chained('job') PathPart('') Args(0) {
$c->stash->{lastBuilds} =
[ $c->stash->{job}->builds->search({ finished => 1 },
{ order_by => 'timestamp DESC', rows => 10, columns => [@buildListColumns] }) ];
{ order_by => 'id DESC', rows => 10, columns => [@buildListColumns] }) ];
$c->stash->{queuedBuilds} = [
$c->stash->{job}->builds->search(
{ finished => 0 },
{ join => ['project']
, order_by => ["priority DESC", "timestamp"]
, order_by => ["priority DESC", "id"]
, '+select' => ['project.enabled']
, '+as' => ['enabled']
}

View File

@ -43,7 +43,7 @@ sub queue :Local {
my ($self, $c) = @_;
$c->stash->{template} = 'queue.tt';
$c->stash->{queue} = [$c->model('DB::Builds')->search(
{finished => 0}, { join => ['project'], order_by => ["priority DESC", "timestamp"], columns => [@buildListColumns], '+select' => ['project.enabled'], '+as' => ['enabled'] })];
{finished => 0}, { join => ['project'], order_by => ["priority DESC", "id"], columns => [@buildListColumns], '+select' => ['project.enabled'], '+as' => ['enabled'] })];
$c->stash->{flashMsg} //= $c->flash->{buildMsg};
}

View File

@ -1039,7 +1039,6 @@ sub restartBuild {
$build->update(
{ finished => 0
, timestamp => time
, busy => 0
, locker => ""
, iscachedbuild => 0

View File

@ -28,7 +28,7 @@ our @EXPORT = qw(
# Columns from the Builds table needed to render build lists.
Readonly our @buildListColumns => ('id', 'finished', 'timestamp', 'project', 'jobset', 'job', 'nixname', 'system', 'priority', 'busy', 'buildstatus', 'releasename');
Readonly our @buildListColumns => ('id', 'finished', 'timestamp', 'stoptime', 'project', 'jobset', 'job', 'nixname', 'system', 'priority', 'busy', 'buildstatus', 'releasename');
sub getBuild {

View File

@ -100,7 +100,7 @@ sub allPrimaryBuilds {
my ($project, $primaryJob) = @_;
my $allPrimaryBuilds = $project->builds->search(
{ jobset => $primaryJob->get_column('jobset'), job => $primaryJob->get_column('job'), finished => 1 },
{ order_by => "timestamp DESC"
{ order_by => "id DESC"
, where => \ attrsToSQL($primaryJob->attrs, "me.id")
});
return $allPrimaryBuilds;
@ -153,7 +153,7 @@ sub findLastJobForBuilds {
, job => $job->get_column('job'), finished => 1
},
{ rows => 1
, order_by => ["buildstatus", "timestamp"]
, order_by => ["buildstatus", "id"]
, where => \ attrsToSQL($job->attrs, "build.id")
})
unless defined $thisBuild;