Jobset job tab: Show eval date rather than eval ID

Eval IDs carry no useful information, so it's better to show the date
of the eval. If the date is recent, a relative date is given (e.g. "3h
ago").
This commit is contained in:
Eelco Dolstra 2015-02-26 13:01:01 +01:00
parent fa1e043526
commit c04c8c2bf1
4 changed files with 24 additions and 6 deletions

View file

@ -120,7 +120,8 @@ sub jobs_tab : Chained('jobsetChain') PathPart('jobs-tab') Args(0) {
{ columns => ['id', 'job', 'finished', 'buildstatus'] }); { columns => ['id', 'job', 'finished', 'buildstatus'] });
foreach my $b (@builds) { foreach my $b (@builds) {
my $jobName = $b->get_column('job'); my $jobName = $b->get_column('job');
$evals->{$eval->id}->{$jobName} = $evals->{$eval->id}->{timestamp} = $eval->timestamp;
$evals->{$eval->id}->{jobs}->{$jobName} =
{ id => $b->id, finished => $b->finished, buildstatus => $b->buildstatus }; { id => $b->id, finished => $b->finished, buildstatus => $b->buildstatus };
$jobs{$jobName} = 1; $jobs{$jobName} = 1;
$nrBuilds++; $nrBuilds++;

View file

@ -2,6 +2,7 @@
USE date; USE date;
USE String; USE String;
USE HTML; USE HTML;
USE Math;
USE mibs=format("%.2f"); USE mibs=format("%.2f");
@ -12,6 +13,22 @@ date.format(timestamp, '%Y-%m-%d %H:%M:%S');
END; END;
BLOCK renderRelativeDate;
ago = date.now - timestamp;
IF ago >= 0 && ago < 60; THEN;
ago _ 's ago';
ELSIF ago >= 0 && ago < 60 * 60; THEN;
Math.int(ago / 60) _ 'm ago';
ELSIF ago >= 0 && ago < 24 * 60 * 60; THEN;
Math.int(ago / (60 * 60)) _ 'h ago';
ELSIF ago >= 0 && ago < 7 * 24 * 60 * 60; THEN;
Math.int(ago / (24 * 60 * 60)) _ 'd ago';
ELSE;
date.format(timestamp, '%Y-%m-%d');
END;
END;
BLOCK renderProjectName %] BLOCK renderProjectName %]
<a [% IF inRow %]class="row-link"[% END %] href="[% c.uri_for('/project' project) %]"><tt>[% project %]</tt></a> <a [% IF inRow %]class="row-link"[% END %] href="[% c.uri_for('/project' project) %]"><tt>[% project %]</tt></a>
[% END; [% END;

View file

@ -20,7 +20,7 @@
}); });
}; };
$('#filter-jobs').submit(function() { $('#filter-jobs').submit(function() {
setFilter($('#filter-jobs').serialize()); setFilter($('#filter-jobs').serialize());
return false; return false;
}); });
@ -49,7 +49,7 @@
[% FOREACH eval IN evalIds %] [% FOREACH eval IN evalIds %]
<th class="rotate-45"> <th class="rotate-45">
<div><span> <div><span>
<a href="[% c.uri_for('/eval' eval) %]">[% eval %]</a> <a href="[% c.uri_for('/eval' eval) %]">[% INCLUDE renderRelativeDate timestamp=evals.$eval.timestamp %]</a>
</span></div></th> </span></div></th>
[% END %] [% END %]
</tr> </tr>
@ -59,11 +59,11 @@
<tr> <tr>
<th><span [% IF inactiveJobs.$j %]class="muted override-link"[% END %]>[% INCLUDE renderJobName project=project.name jobset=jobset.name job=j %]</span></th> <th><span [% IF inactiveJobs.$j %]class="muted override-link"[% END %]>[% INCLUDE renderJobName project=project.name jobset=jobset.name job=j %]</span></th>
[% FOREACH eval IN evalIds %] [% FOREACH eval IN evalIds %]
<td>[% r = evals.$eval.$j; IF r.id %]<a href="[% c.uri_for('/build' r.id) %]">[% INCLUDE renderBuildStatusIcon size=16 build=r %]</a>[% END %]</td> <td>[% r = evals.$eval.jobs.$j; IF r.id %]<a href="[% c.uri_for('/build' r.id) %]">[% INCLUDE renderBuildStatusIcon size=16 build=r %]</a>[% END %]</td>
[% END %] [% END %]
</tr> </tr>
[% END %] [% END %]
</tbody> </tbody>
</table> </table>
[% END %] [% END %]

View file

@ -9,7 +9,7 @@ td.centered {
text-align: center; text-align: center;
} }
.table-header-rotated th.rotate-45{ .table-header-rotated th.rotate-45 {
height: 80px; height: 80px;
width: 40px; width: 40px;
min-width: 40px; min-width: 40px;