Permalink
Browse files

Update the index page to actually work

  • Loading branch information...
1 parent 813b084 commit d68504db1625d70b45323d40b9f8cd5e17c6376a @atrodo committed Sep 8, 2011
Showing with 180 additions and 53 deletions.
  1. +70 −5 lib/itfy/Controller/Root.pm
  2. +98 −48 root/src/index.tt2
  3. +12 −0 root/static/style.css
@@ -29,15 +29,80 @@ The root page (/)
sub index :Path :Args(0) {
my ( $self, $c ) = @_;
- # Hello World
- #$c->response->body( $c->welcome_message );
- my $machine = $c->model("ItfyDB::Machine")->find({name => "ipfy"});
+ my $machine = $c->model("ItfyDB::Machine")->find({name => "atrodo.org"});
my $project = $c->model("ItfyDB::Project")->find({name => "Parrot"});
- my $cmd_rs = $project->bench_cmds;
-
+ my $cmd_rs = $c->model("ItfyDB::BenchCmd");
+ my $branch_rs = $project->bench_branch;
+
+ my $branches = [];
+
+ my $results_by_cmd = {};
+
+ while (my $branch = $branch_rs->next)
+ {
+ my $revs = [];
+ my $rev_rs = $branch->revs->search({
+ "bench_run.success" => 'true',
+ "bench_run.machine_id" => $machine->machine_id,
+ }, {
+ prefetch => [{bench_run => "bench_results"}, {"children" => {bench_run => "bench_results"}} ],
+ #'+select' => [{max => 'submit_stamp', '-as' => 'max_submit_stamp'}],
+ #group_by => [qw/me.bench_branch_rev_id/],
+ #having => {submit_stamp => \"= max_submit_stamp"},
+ });
+
+ $rev_rs->result_class('DBIx::Class::ResultClass::HashRefInflator');
+
+ #push @$branches, {
+ # name => $branch->name,
+ # revs => $rev_rs,
+ #};
+ #die Data::Dumper::Dumper($rev_rs->all);
+
+ my $extract;
+ $extract = sub
+ {
+ my $rev = shift;
+ foreach my $child (@{ $rev->{children} })
+ {
+ $extract->($child);
+ }
+
+ my $newest_submit = 0;
+
+ foreach my $run (@{ $rev->{bench_run} })
+ {
+ next
+ if $newest_submit > $run->{submit_stamp};
+
+ $newest_submit = $run->{submit_stamp};
+
+ foreach my $result (@{ $run->{bench_results} })
+ {
+ push @{ $results_by_cmd->{$result->{bench_cmd_id}}}, {
+ %$result,
+ submit_stamp => $run->{submit_stamp},
+ revision => $rev->{revision},
+ revision_aka => $rev->{revision_aka},
+ revision_stamp => $rev->{revision_stamp},
+ revision_date => $rev->{revision_date},
+ };
+ }
+ }
+ };
+
+ while (my $rev = $rev_rs->next)
+ {
+ $extract->($rev);
+ }
+ }
+
+ # qw/bench_branch_rev_id bench_run bench_cmd_id
+ $c->stash->{results_by_cmd} = $results_by_cmd;
$c->stash->{machine} = $machine;
$c->stash->{project} = $project;
$c->stash->{cmd_rs} = $cmd_rs;
+ $c->stash->{branches} = $branches;
$c->stash->{template} = 'index.tt2';
}
View
@@ -11,88 +11,106 @@
print $n;
[% END %]
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.js"></script>
- <script type="text/javascript" src="static/flot/jquery.flot.js"></script>
+ <script type="text/javascript" src="static/flot/jquery.flot.min.js"></script>
+ <script type="text/javascript" src="static/flot/jquery.flot.selection.min.js"></script>
<!--[if IE]><script type="text/javascript" src="static/excanvas.compiled.js"></script><![endif]-->
</head>
<body>
<div id="graph-container">
[% WHILE (cmd = cmd_rs.next) %]
- [% PERL %]
- my $cmd = $stash->get("cmd");
- $stash->set("result_rows", [$cmd->bench_results_rs->search(
- {
- }, {
- order_by => "revision_stamp desc",
- rows => 20,
- '+select' => [{max => 'submit_stamp', '-as' => 'max_submit_stamp'}],
- #distinct => 1,
- group_by => [qw/revision/],
- having => {submit_stamp => \"= max_submit_stamp"},
- })->all]
- );
- [% END %]
- [% result_rows = result_rows.reverse %]
+ [% IF !results_by_cmd.exists(cmd.bench_cmd_id); NEXT; END %]
+
<div class="cmd-label">[% cmd.name %]</div>
<div id="[% cmd.id %]">
- [% last_speed = undef %]
- <!-- [% result_rows.size %] -->
- <div class="details_hold">
- [%~ FOREACH result IN result_rows ~%]
- <div class="point_details">
- Speed: <span class="speed">[% round(result.avg_time, 1000) %]</span>s
- <br/>
- [% IF last_speed %]
- [% delta = last_speed - result.avg_time %]
- &Delta; <span class="delta">[% round(delta, 1000) %]</span>s
- [% percent = round(((delta / last_speed) * 100), 100) %]
- [% IF percent >= 0 %]
- (<span class='percent'>[% percent %]</span>% Better)
- [% ELSE %]
- (<span class='percent'>[% 0-percent %]</span>% Worse)
+ [% last_speed = undef %]
+ [% last_stamp = undef %]
+ <div class="details_hold">
+ [%~ FOREACH result IN
+ results_by_cmd.item(cmd.bench_cmd_id).sort('revision_stamp') %]
+ <div class="point_details">
+ Speed: <span class="speed">[% round(result.avg_time, 1000) %]</span>s
+ <br/>
+ [% FILTER collapse %]
+ [% IF last_speed %]
+ [% delta = last_speed - result.avg_time %]
+ &Delta; <span class="delta">[% round(delta, 1000) %]</span>s
+ [% percent = round(((delta / last_speed) * 100), 100) %]
+ [% IF percent >= 0 %]
+ (<span class='percent'>[% percent %]</span>% Better)
+ [% ELSE %]
+ (<span class='percent'>[% 0-percent %]</span>% Worse)
+ [% END %]
+ <br/>
+ [% END %]
+ [% last_speed = result.avg_time %]
[% END %]
+ Revision <span class="revision">[% result.revision.substr(0,8) %]</span>
+ [% IF result.revision_aka.defined ~%]
+ (<span class='rev_aka'>[% result.revision_aka %]</span>)
+ [%~ END %]
<br/>
- [% END %]
- [% last_speed = result.avg_time %]
- Revision <span class="revision">[% result.revision.substr(0,8) %]</span>
- [% IF result.revision_aka.defined %]
- (<span class='rev_aka'>[% result.revision_aka %]</span>)
- [% END %]
- <br/>
- Dated <span class='rev_date'>[% date.format(result.revision_stamp) %]</span>
+ Dated <span class='rev_date'>[% date.format(result.revision_stamp) %]</span>
+ <span class='rev_stamp hidden'>[% result.revision_stamp %]</span>
+ </div>
+ [% last_stamp = result.revision_stamp %]
+ [%~ END ~%]
</div>
- [%~ END ~%]
- </div>
- [% #CALL result_rs.reset %]
</div>
+ <div id="[% cmd.id %]_overview"></div>
<script type="text/javascript">
$(function()
{
var graph_div = $('#[% cmd.id %]');
+ var overview_div = $('#[% cmd.id %]_overview');
+
graph_div
.addClass('cmd-graph')
+ overview_div
+ .addClass('cmd-overview')
+
+ var dataset = [];
+
var point_details = graph_div.find('div.point_details').detach();
+ point_details
+ .each(function(i)
+ {
+ var $this = $(this)
+ dataset.push([
+ $this
+ .find('.rev_stamp')
+ .text() * 1000
+ ,
+ $this
+ .find('.speed')
+ .text()
+ ])
+ })
+
var data = {
- data: [
- [%~ FOREACH result IN result_rows ~%]
- [ [% result.revision_stamp * 1000 %], [% result.avg_time %] ],
- [%~ END ~%]
- null],
+ data: dataset,
lines: { show: true },
points: { show: true },
hoverable: true,
clickable: true
};
var options =
{
+ series:
+ {
+ points: { show: true },
+ lines: { show: true }
+ },
yaxis:
{
min: 0,
tickFormatter: function (v, axis) { return Math.floor(v * 1000) + "ms"; }
},
xaxis:
{
+ min: [% (last_stamp - 60 * 24 * 60 * 60) * 1000 %],
+ max: [% last_stamp * 1000 %],
tickFormatter: function (v, axis) { return (new Date(v)).toDateString(); }
},
legend:
@@ -105,7 +123,39 @@
clickable: true
}
};
- $.plot(graph_div, [data], options);
+ var plot = $.plot(graph_div, [data], options);
+
+ var overview = $.plot(overview_div, [data],
+ {
+ series:
+ {
+ points: { show: false },
+ lines: { show: true, lineWidth: 1 },
+ shadowSize: 0
+ },
+ xaxis: { ticks: [], mode: "time" },
+ yaxis: { ticks: [], min: 0, autoscaleMargin: 0.1 },
+ selection: { mode: "x" }
+ }
+ )
+
+ graph_div
+ .bind("plotselected", function (event, ranges) {
+ // do the zooming
+ plot = $.plot(graph_div, [dataset],
+ $.extend(true, {}, options, {
+ xaxis: { min: ranges.xaxis.from, max: ranges.xaxis.to }
+ })
+ );
+
+ // don't fire event on the overview to prevent eternal loop
+ overview.setSelection(ranges, true);
+ });
+
+ overview_div
+ .bind("plotselected", function (event, ranges) {
+ plot.setSelection(ranges);
+ });
tooltip = $("<div />")
.addClass('tooltip')
View
@@ -4,6 +4,11 @@ body {
color:#000;
}
+div.hidden
+{
+ display: none;
+}
+
div.cmd-label
{
font-size: 2em;
@@ -17,6 +22,13 @@ div.cmd-graph
height: 240px;
}
+div.cmd-overview
+{
+ margin-top:20px;
+ width: 640px;
+ height:50px
+}
+
div.details_hold
{
width: 16em;

0 comments on commit d68504d

Please sign in to comment.