From 77d4a8c0270f27768decb3035a4453b9805d2014 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 15 Feb 2010 10:21:11 +0000 Subject: [PATCH] * 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). --- src/script/hydra_update_gc_roots.pl | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/script/hydra_update_gc_roots.pl b/src/script/hydra_update_gc_roots.pl index e95faa5e..394d0b26 100755 --- a/src/script/hydra_update_gc_roots.pl +++ b/src/script/hydra_update_gc_roots.pl @@ -22,7 +22,8 @@ sub registerRoot { sub keepBuild { my ($build) = @_; print STDERR " keeping build ", $build->id, " (", - strftime("%Y-%m-%d %H:%M:%S", localtime($build->timestamp)), ")\n"; + $build->system, "; ", + strftime("%Y-%m-%d %H:%M:%S", localtime($build->timestamp)), ")\n"; if (isValidPath($build->outpath)) { registerRoot $build->outpath; } else { @@ -45,16 +46,20 @@ foreach my $project ($db->resultset('Projects')->all) { # platform. # !!! Take time into account? E.g. don't delete builds that # are younger than N days. - my @recentBuilds = $job->builds->search( - { finished => 1 - , buildStatus => 0 # == success - }, - { join => 'resultInfo' - , order_by => 'timestamp DESC' - , rows => 3 # !!! should make this configurable - }); - - keepBuild $_ foreach @recentBuilds; + my @systems = $job->builds->search({ }, { select => ["system"], distinct => 1 })->all; + + foreach my $system (@systems) { + my @recentBuilds = $job->builds->search( + { finished => 1 + , buildStatus => 0 # == success + , system => $system->system + }, + { join => 'resultInfo' + , order_by => 'id DESC' + , rows => 3 # !!! should make this configurable + }); + keepBuild $_ foreach @recentBuilds; + } } # Go over all views in this project.