Skip to content
This repository has been archived by the owner on Feb 3, 2021. It is now read-only.

Commit

Permalink
implement view of most recent reports
Browse files Browse the repository at this point in the history
  • Loading branch information
FROGGS committed Oct 30, 2014
1 parent 11f02bb commit b816c3c
Show file tree
Hide file tree
Showing 4 changed files with 115 additions and 8 deletions.
75 changes: 71 additions & 4 deletions app.pl
Expand Up @@ -28,7 +28,8 @@
template 'main.tt', {
:breadcrumb(['Distributions']),
:content( template 'dists.tt', { :$dist-lines })
}
},
&request
}

get /^ '/dist/' (.+) / => sub ($distname) {
Expand Down Expand Up @@ -88,7 +89,67 @@
:stats( template 'stats.tt', [@osnames.sort], $%stats, &template ),
:report-tables($reports)
}),
},
&request
}

get '/recent' => sub {
my $sth = $dbh.prepare("SELECT `id`,`grade`,`distname`,`distauth`,`distver`,`compver`,`backend`,`osname`,`osver`,`arch`
FROM `cpandatesters`.`reports`
ORDER BY `id` DESC
LIMIT 100");
$sth.execute;
my @reports;
my @osnames = <linux mswin32 darwin netbsd openbsd freebsd solaris>;
my %stats;
while $sth.fetchrow_hashref -> $/ {
%stats{$<compver>}{$<osname>}{$<backend>}{$<grade>}++;
@osnames.push: $<osname> unless $<osname> ~~ any @osnames;

$<distver> = '0' if $<distver> eq '*';
$<breadcrumb> = '/recent';
@reports.push: template 'recent-line.tt', $/
}
for @osnames -> $osname {
for %stats.keys -> $compver is copy {
for <moar jvm parrot> -> $backend {
my $all = [+] %stats{$compver}{$osname}{$backend}.values;
for <PASS FAIL NA> -> $grade {
if %stats{$compver}{$osname}{$backend}{$grade} {
%stats{$compver}{$osname}{$backend}{$grade} /= $all / 100;
if 0 < %stats{$compver}{$osname}{$backend}{$grade} < 2 {
%stats{$compver}{$osname}{$backend}{$grade}.=ceiling
}
else {
%stats{$compver}{$osname}{$backend}{$grade}.=floor;
}
}
else {
%stats{$compver}{$osname}{$backend}{$grade} = 0
}
}
my $deviation = 100 - [+] %stats{$compver}{$osname}{$backend}.values;
if -10 < $deviation < 10 {
my $grade = %stats{$compver}{$osname}{$backend}.sort(*.value).reverse[0].key;
%stats{$compver}{$osname}{$backend}{$grade} += $deviation;
}
}
}
}

template 'main.tt', {
:breadcrumb(['Most recent reports']),
:content(
'<h4>Code quality across operating system, compiler version and backend</h4>' ~
template 'dist.tt', {
:stats( template 'stats.tt', [@osnames.sort], $%stats, &template ),
:report-tables(
'<h4>Top 100 reports</h4>' ~
template 'recent-table.tt', { :report-lines(@reports.join("\n")) }
)
}),
},
&request
}

get / '/report/' (.+) '/' (\d+) / => sub ($path, $id) {
Expand All @@ -99,13 +160,19 @@
if $sth.fetchrow_hashref -> $r {
my @path = $path.Str.split('/');
my $breadcrumb = ["Report $id"];
if @path[0] eq 'dist' {
$breadcrumb.unshift: 'Distributions' => '/dists', @path[1] => "/dist/@path[1]"
given @path[0] {
when 'dist' {
$breadcrumb.unshift: 'Distributions' => '/dists', @path[1] => "/dist/@path[1]"
}
when 'recent' {
$breadcrumb.unshift: 'Most recent reports' => '/recent'
}
}
template 'main.tt', {
:$breadcrumb,
:content( template 'report-details.tt', $r, from-json $r<raw>)
}
},
&request
}
else {
status 404;
Expand Down
8 changes: 4 additions & 4 deletions views/main.tt
@@ -1,4 +1,4 @@
% my ($x) = @_;
% my ($x, &request) = @_;
<!DOCTYPE html>
<html lang="en">
<head>
Expand Down Expand Up @@ -169,9 +169,9 @@
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="navbarCollapse">
<ul class="nav navbar-nav">
<li class="active"><a href="/dists">Distributions</a></li>
<li><a href="/authors" title="NYI">Authors</a></li>
<li><a href="/recent" title="NYI">Most recent reports</a></li>
<li<%= request.path ~~ /^ '/dists' [ \b | $ ] / ?? ' class="active"' !! '' %>><a href="/dists">Distributions</a></li>
<li<%= request.path ~~ /^ '/authors' [ \b | $ ] / ?? ' class="active"' !! '' %>><a href="/authors" title="NYI">Authors</a></li>
<li<%= request.path ~~ /^ '/recent' [ \b | $ ] / ?? ' class="active"' !! '' %>><a href="/recent">Most recent reports</a></li>
</ul>
</div>
</div>
Expand Down
22 changes: 22 additions & 0 deletions views/recent-line.tt
@@ -0,0 +1,22 @@
% my ($x) = @_;
<tr class="clickableRow" href="/report<%= $x<breadcrumb> %>/<%= $x<id> %>">
<td>
<div class="progress" style="margin-bottom: 0">
<div class="progress-bar progress-bar-<%=
do given $x<grade> {
when 'PASS' { 'success' }
when 'FAIL' { 'danger' }
default { 'warning' }
} %>" style="width: 100%">
<span><%= $x<grade> %></span>
</div>
</div>
</td>
<td><%= $x<distname> %></td>
<td><%= $x<distver> %></td>
<td><%= $x<compver> %></td>
<td><%= $x<backend> %></td>
<td><%= $x<osname> %></td>
<td><%= $x<osver> %></td>
<td><%= $x<arch> %></td>
</tr>
18 changes: 18 additions & 0 deletions views/recent-table.tt
@@ -0,0 +1,18 @@
% my ($x) = @_;
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th width="10%">Grade</th>
<th>Distribution name</th>
<th>Dist version</th>
<th>Compiler version</th>
<th>Backend</th>
<th>OS name</th>
<th>OS version</th>
<th>Architecture</th>
</tr>
</thead>
<tbody>
<%= $x<report-lines> %>
</tbody>
</table>

0 comments on commit b816c3c

Please sign in to comment.