Skip to content

Commit

Permalink
add distribution list and individual reports
Browse files Browse the repository at this point in the history
Lots of work to do here:

* Allow filtering the distribution list by grade, lang version,
  platform, and tester.
* Only show the latest N versions with a button for more
* Paginate the report list using Moai

But it's a start!
  • Loading branch information
preaction committed Jan 14, 2020
1 parent 5e22f7f commit 2d5cac7
Show file tree
Hide file tree
Showing 5 changed files with 152 additions and 11 deletions.
4 changes: 2 additions & 2 deletions dist.ini
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ Mojolicious = 7.40 ; Added MOJO_LOG_SHORT
Mojolicious::Plugin::Config = 0
Mojolicious::Plugin::AssetPack = 0
Mojolicious::Plugin::OAuth2 = 0
CPAN::Testers::Schema = 0.025
CPAN::Testers::Schema = 0.026
File::Share = 0
Log::Any = 1.045 ; Returns message and faster
Log::Any::Adapter::MojoLog = 0.02
Expand All @@ -143,7 +143,7 @@ Minion::Backend::mysql = 0.15 ; Support MySQL 8
Mojolicious::Plugin::Yancy = 1.005 ; Support backend hash config
Mojo::mysql = 1.04
Email::Stuffer = 0
Mojolicious::Plugin::Moai = 0.003
Mojolicious::Plugin::Moai = 0.006

; Requried by AssetPack because I'm using CSS and JS...
CSS::Minifier::XS = 0
Expand Down
13 changes: 4 additions & 9 deletions lib/CPAN/Testers/Web.pm
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,7 @@ sub startup ( $app ) {

$r->get( '/dist/:dist/#version', { version => 'latest' } )
->name( 'reports.dist' )
->to( cb => sub {
my ( $c ) = @_;
$c->render( 'dist' );
} );
->to( 'reports#dist_reports' );

$r->get( '/dist' )
->name( 'dist-search' )
Expand Down Expand Up @@ -264,11 +261,9 @@ sub startup ( $app ) {
} );

$r->get( '/report/:guid' )
->name( 'report' )
->to( cb => sub {
my ( $c ) = @_;
$c->render( 'report' );
} );
->to( 'reports#report' )
->name( 'reports.report' )
;

$r->get( '/legacy/cpan/report/:id' )
->name( 'legacy-view-report' )
Expand Down
60 changes: 60 additions & 0 deletions lib/CPAN/Testers/Web/Controller/Reports.pm
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,64 @@ sub recent_uploads( $c ) {
);
}

=method dist_reports
List the reports for a distribution / version.
=cut

sub dist_reports( $c ) {
my $dist = $c->stash( 'dist' );
my $version = $c->stash( 'version' );
my @releases = $c->schema->perl5->resultset( 'Release' )->by_dist( $dist )
->search(
undef,
{
join => 'upload',
order_by => { -desc => 'upload.released' },
}
)
->all;
if ( $version eq 'latest' ) {
$version = $releases[0]->version;
}

my $reports = $c->schema->perl5->resultset( 'Stats' )
->search(
{
dist => $dist,
version => $version,
},
);

$c->render(
'reports/dist_reports',
releases => \@releases,
reports => [
map +{
guid => $_->guid,
grade => $_->grade,
lang_version => $_->lang_version,
platform => $_->platform,
tester_name => $_->tester_name,
},
$reports->all,
],
);
}

=method report
View a single report
=cut

sub report( $c ) {
my $id = $c->stash( 'guid' );
$c->render(
'reports/report',
report => $c->schema->perl5->resultset( 'TestReport' )->find( $id ),
);
}

1;
48 changes: 48 additions & 0 deletions share/templates/reports/dist_reports.html.ep
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@

% my $dist = stash( 'dist' ) . ' (' . stash( 'version' ) . ')';
% title $dist;

<div class="container">
<div class="row">
<div class="col-md-12">
<h1><%= stash 'dist' %></h1>
</div>
</div>
<div class="row">
<div class="col-md-3">
<h2>Releases</h2>

<div class="list-group">
% for my $r ( @$releases ) {
<a href="<%= url_with { version => $r->version } %>" class="list-group-item <%= stash( 'version' ) == 1.000001 || stash( 'version' ) eq 'latest' ? "active" : "" %>">
<%= $r->version %>
<span class="pull-right">
<span class="label label-success"><%= $r->pass %></span>
<span class="label label-danger"><%= $r->fail %></span>
</span>
</a>
% }
</div>

</div>
<div class="col-md-9">
<h2>Reports (<%= stash 'version' %>)</h2>

<%= include 'moai/table',
items => $reports,
columns => [
{ title => '', key => 'guid', link_to => 'reports.report' },
{ title => 'Grade', key => 'grade' },
{ title => 'Language', key => 'lang_version' },
{ title => 'Platform', key => 'platform' },
{ title => 'Tester', key => 'tester_name' },
],
classes => {
table => 'table-striped table-hover',
},
%>

</div>
</div>
</div>

38 changes: 38 additions & 0 deletions share/templates/reports/report.html.ep
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@

<% title sprintf 'Report - %s v%s %s %s',
$report->dist_name, $report->dist_version, $report->lang_version,
$report->platform,
;
%>

<div class="container">
<div class="row">
<h1><%=
sprintf '%s v%s %s %s',
$report->dist_name, $report->dist_version, $report->lang_version,
$report->platform,
;
%></h1>

<dl class="dl-horizontal">
<dt>Status</dt>
<dd><%= ucfirst $report->grade %></dd>
<dt>From</dt>
<dd><%= $report->tester_name %></dd>
<dt>Dist</dt>
<dd><%= link_to 'reports.dist', { dist => $report->dist_name, version => $report->dist_version }, begin %>
<%= $report->dist_name %> v<%= $report->dist_version %>
<% end %></dd>
<dt>Platform</dt>
<dd><%= join ' ', $report->lang_version, $report->platform %></dd>
<dt>Date</dt>
<dd><%= $report->created->datetime( ' ' ) %></dd>
<dt>ID</dt>
<dd><%= $report->id %></dd>
</dl>

<pre><%= $report->text %></pre>

</div>
</div>

0 comments on commit 2d5cac7

Please sign in to comment.