* Keep the 3 most recent builds for every platform for every job.

Previously it just kept the 3 most recent builds for every job
  (contrary to what the comment said).
This commit is contained in:
Eelco Dolstra 2010-02-15 10:21:11 +00:00
parent 12edc4b8e2
commit 77d4a8c027

View file

@ -22,6 +22,7 @@ sub registerRoot {
sub keepBuild { sub keepBuild {
my ($build) = @_; my ($build) = @_;
print STDERR " keeping build ", $build->id, " (", print STDERR " keeping build ", $build->id, " (",
$build->system, "; ",
strftime("%Y-%m-%d %H:%M:%S", localtime($build->timestamp)), ")\n"; strftime("%Y-%m-%d %H:%M:%S", localtime($build->timestamp)), ")\n";
if (isValidPath($build->outpath)) { if (isValidPath($build->outpath)) {
registerRoot $build->outpath; registerRoot $build->outpath;
@ -45,17 +46,21 @@ foreach my $project ($db->resultset('Projects')->all) {
# platform. # platform.
# !!! Take time into account? E.g. don't delete builds that # !!! Take time into account? E.g. don't delete builds that
# are younger than N days. # are younger than N days.
my @systems = $job->builds->search({ }, { select => ["system"], distinct => 1 })->all;
foreach my $system (@systems) {
my @recentBuilds = $job->builds->search( my @recentBuilds = $job->builds->search(
{ finished => 1 { finished => 1
, buildStatus => 0 # == success , buildStatus => 0 # == success
, system => $system->system
}, },
{ join => 'resultInfo' { join => 'resultInfo'
, order_by => 'timestamp DESC' , order_by => 'id DESC'
, rows => 3 # !!! should make this configurable , rows => 3 # !!! should make this configurable
}); });
keepBuild $_ foreach @recentBuilds; keepBuild $_ foreach @recentBuilds;
} }
}
# Go over all views in this project. # Go over all views in this project.