* Show global and per-project statistics.

This commit is contained in:
Eelco Dolstra 2008-11-26 23:49:51 +00:00
parent 043127c3d4
commit 38a1b0d7ef
4 changed files with 65 additions and 46 deletions

View file

@ -46,11 +46,36 @@ sub getBuild {
}
sub getBuildStats {
my ($c, $builds) = @_;
$c->stash->{finishedBuilds} = $builds->search({finished => 1}) || 0;
$c->stash->{succeededBuilds} = $builds->search(
{finished => 1, buildStatus => 0},
{join => 'resultInfo'}) || 0;
$c->stash->{scheduledBuilds} = $builds->search({finished => 0}) || 0;
$c->stash->{busyBuilds} = $builds->search(
{finished => 0, busy => 1},
{join => 'schedulingInfo'}) || 0;
$c->stash->{totalBuildTime} = $builds->search({},
{join => 'resultInfo', select => {sum => 'stoptime - starttime'}, as => ['sum']})
->first->get_column('sum') || 0;
}
sub index :Path :Args(0) {
my ($self, $c) = @_;
$c->stash->{template} = 'index.tt';
getBuildStats($c, $c->model('DB::Builds'));
$c->stash->{allBuilds} = [$c->model('DB::Builds')->search(
{finished => 1}, {order_by => "timestamp DESC"})];
# Get the latest finished build for each unique job.
$c->stash->{latestBuilds} = [$c->model('DB::Builds')->search(undef,
{ join => 'resultInfo'
@ -272,25 +297,7 @@ sub project :Local {
$c->stash->{curProject} = $project;
$c->stash->{finishedBuilds} = $c->model('DB::Builds')->search(
{project => $projectName, finished => 1});
$c->stash->{succeededBuilds} = $c->model('DB::Builds')->search(
{project => $projectName, finished => 1, buildStatus => 0},
{join => 'resultInfo'});
$c->stash->{scheduledBuilds} = $c->model('DB::Builds')->search(
{project => $projectName, finished => 0});
$c->stash->{busyBuilds} = $c->model('DB::Builds')->search(
{project => $projectName, finished => 0, busy => 1},
{join => 'schedulingInfo'});
$c->stash->{totalBuildTime} = $c->model('DB::Builds')->search(
{project => $projectName},
{join => 'resultInfo', select => {sum => 'stoptime - starttime'}, as => ['sum']})
->first->get_column('sum');
$c->stash->{totalBuildTime} = 0 unless defined $c->stash->{totalBuildTime};
getBuildStats($c, scalar $project->builds);
$c->stash->{jobNames} =
[$c->model('DB::Builds')->search({project => $projectName}, {select => [{distinct => 'attrname'}], as => ['attrname']})];

View file

@ -61,4 +61,36 @@
[% END -%]
</tbody>
</table>
[% END %]
[% BLOCK showBuildStats %]
<table class="layoutTable">
<tr>
<th>Finished builds:</th>
<td>[% finishedBuilds %]</td>
</tr>
<tr>
<th><img src="/static/images/success.gif" /> Succeeded builds:</th>
<td>[% succeededBuilds %]</td>
</tr>
<tr>
<th><img src="/static/images/failure.gif" /> Failed builds:</th>
<td>[% finishedBuilds - succeededBuilds %]</td>
</tr>
<tr>
<th>Total build time:</th>
<td>[% totalBuildTime %]s</td>
</tr>
<tr>
<th>Scheduled builds:</th>
<td>[% scheduledBuilds %]</td>
</tr>
<tr>
<th>Currently executing builds:</th>
<td>[% busyBuilds %]</td>
</tr>
</table>
[% END %]

View file

@ -5,6 +5,11 @@
<h1>Hydra Overview</h1>
<h2>Statistics</h2>
[% PROCESS showBuildStats %]
<h2>Job status</h2>
<p>Below are the latest builds for each job.</p>

View file

@ -245,7 +245,7 @@
<h2>Jobs</h2>
[% IF jobName && jobNames.size > 0 %]
[% IF jobNames && jobNames.size > 0 %]
<ul>
[% FOREACH jobName IN jobNames -%]
@ -262,32 +262,7 @@
<h2>Statistics</h2>
<table class="layoutTable">
<tr>
<th>Finished builds:</th>
<td>[% finishedBuilds %]</td>
</tr>
<tr>
<th><img src="/static/images/success.gif" /> Succeeded builds:</th>
<td>[% succeededBuilds %]</td>
</tr>
<tr>
<th><img src="/static/images/failure.gif" /> Failed builds:</th>
<td>[% finishedBuilds - succeededBuilds %]</td>
</tr>
<tr>
<th>Total build time:</th>
<td>[% totalBuildTime %]s</td>
</tr>
<tr>
<th>Scheduled builds:</th>
<td>[% scheduledBuilds %]</td>
</tr>
<tr>
<th>Currently executing builds:</th>
<td>[% busyBuilds %]</td>
</tr>
</table>
[% PROCESS showBuildStats %]
[% END %]