forked from lix-project/hydra
* Show global and per-project statistics.
This commit is contained in:
parent
043127c3d4
commit
38a1b0d7ef
|
@ -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) {
|
sub index :Path :Args(0) {
|
||||||
my ($self, $c) = @_;
|
my ($self, $c) = @_;
|
||||||
$c->stash->{template} = 'index.tt';
|
$c->stash->{template} = 'index.tt';
|
||||||
|
|
||||||
|
getBuildStats($c, $c->model('DB::Builds'));
|
||||||
|
|
||||||
$c->stash->{allBuilds} = [$c->model('DB::Builds')->search(
|
$c->stash->{allBuilds} = [$c->model('DB::Builds')->search(
|
||||||
{finished => 1}, {order_by => "timestamp DESC"})];
|
{finished => 1}, {order_by => "timestamp DESC"})];
|
||||||
|
|
||||||
# Get the latest finished build for each unique job.
|
# Get the latest finished build for each unique job.
|
||||||
$c->stash->{latestBuilds} = [$c->model('DB::Builds')->search(undef,
|
$c->stash->{latestBuilds} = [$c->model('DB::Builds')->search(undef,
|
||||||
{ join => 'resultInfo'
|
{ join => 'resultInfo'
|
||||||
|
@ -272,25 +297,7 @@ sub project :Local {
|
||||||
|
|
||||||
$c->stash->{curProject} = $project;
|
$c->stash->{curProject} = $project;
|
||||||
|
|
||||||
$c->stash->{finishedBuilds} = $c->model('DB::Builds')->search(
|
getBuildStats($c, scalar $project->builds);
|
||||||
{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};
|
|
||||||
|
|
||||||
$c->stash->{jobNames} =
|
$c->stash->{jobNames} =
|
||||||
[$c->model('DB::Builds')->search({project => $projectName}, {select => [{distinct => 'attrname'}], as => ['attrname']})];
|
[$c->model('DB::Builds')->search({project => $projectName}, {select => [{distinct => 'attrname'}], as => ['attrname']})];
|
||||||
|
|
|
@ -61,4 +61,36 @@
|
||||||
[% END -%]
|
[% END -%]
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</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 %]
|
[% END %]
|
|
@ -5,6 +5,11 @@
|
||||||
<h1>Hydra Overview</h1>
|
<h1>Hydra Overview</h1>
|
||||||
|
|
||||||
|
|
||||||
|
<h2>Statistics</h2>
|
||||||
|
|
||||||
|
[% PROCESS showBuildStats %]
|
||||||
|
|
||||||
|
|
||||||
<h2>Job status</h2>
|
<h2>Job status</h2>
|
||||||
|
|
||||||
<p>Below are the latest builds for each job.</p>
|
<p>Below are the latest builds for each job.</p>
|
||||||
|
|
|
@ -245,7 +245,7 @@
|
||||||
|
|
||||||
<h2>Jobs</h2>
|
<h2>Jobs</h2>
|
||||||
|
|
||||||
[% IF jobName && jobNames.size > 0 %]
|
[% IF jobNames && jobNames.size > 0 %]
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
[% FOREACH jobName IN jobNames -%]
|
[% FOREACH jobName IN jobNames -%]
|
||||||
|
@ -262,32 +262,7 @@
|
||||||
|
|
||||||
<h2>Statistics</h2>
|
<h2>Statistics</h2>
|
||||||
|
|
||||||
<table class="layoutTable">
|
[% PROCESS showBuildStats %]
|
||||||
<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 %]
|
[% END %]
|
||||||
|
|
Loading…
Reference in a new issue