From 1b12daa03266e98ece958d1c5aa5099f96ab1a2a Mon Sep 17 00:00:00 2001 From: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Tue, 7 Oct 2014 12:59:09 +0200 Subject: [PATCH] Move the build time chart to the job page --- src/lib/Hydra/Controller/Build.pm | 26 ----------- src/lib/Hydra/Controller/Job.pm | 12 +++++ src/root/build-history-tab.tt | 73 ------------------------------- src/root/build.tt | 3 -- src/root/common.tt | 2 +- src/root/job.tt | 8 +++- 6 files changed, 19 insertions(+), 105 deletions(-) delete mode 100644 src/root/build-history-tab.tt diff --git a/src/lib/Hydra/Controller/Build.pm b/src/lib/Hydra/Controller/Build.pm index 411065d3..9a702ea8 100644 --- a/src/lib/Hydra/Controller/Build.pm +++ b/src/lib/Hydra/Controller/Build.pm @@ -405,32 +405,6 @@ sub runtime_deps : Chained('buildChain') PathPart('runtime-deps') { } -sub history_graphs : Chained('buildChain') PathPart('history-graphs') { - my ($self, $c) = @_; - my $build = $c->stash->{build}; - if ($build->finished) { - $c->stash->{prevBuilds} = [$c->model('DB::Builds')->search( - { project => $c->stash->{project}->name - , jobset => $c->stash->{jobset}->name - , job => $c->stash->{job}->name - , 'me.system' => $build->system - , finished => 1 - , buildstatus => 0 - , 'me.id' => { '<=' => $build->id } - } - , { join => "actualBuildStep" - , "+select" => ["actualBuildStep.stoptime - actualBuildStep.starttime"] - , "+as" => ["actualBuildTime"] - , order_by => "me.id DESC" - , rows => 50 - } - ) - ]; - } - $c->stash->{template} = 'build-history-tab.tt'; -} - - sub nix : Chained('buildChain') PathPart('nix') CaptureArgs(0) { my ($self, $c) = @_; diff --git a/src/lib/Hydra/Controller/Job.pm b/src/lib/Hydra/Controller/Job.pm index aa708bb2..274d9604 100644 --- a/src/lib/Hydra/Controller/Job.pm +++ b/src/lib/Hydra/Controller/Job.pm @@ -80,6 +80,18 @@ sub overview : Chained('job') PathPart('') Args(0) { } +sub build_times : Chained('job') PathPart('build-times') Args(0) { + my ($self, $c) = @_; + my @res = $c->stash->{job}->builds->search( + { finished => 1, buildstatus => 0, closuresize => { '!=', 0 } }, + { join => "actualBuildStep" + , "+select" => ["actualBuildStep.stoptime - actualBuildStep.starttime"] + , "+as" => ["actualBuildTime"], + , order_by => "id" }); + $self->status_ok($c, entity => [ map { { id => $_->id, timestamp => $_ ->timestamp, value => $_->get_column('actualBuildTime') } } @res ]); +} + + sub closure_sizes : Chained('job') PathPart('closure-sizes') Args(0) { my ($self, $c) = @_; my @res = $c->stash->{job}->builds->search( diff --git a/src/root/build-history-tab.tt b/src/root/build-history-tab.tt deleted file mode 100644 index 8d274f71..00000000 --- a/src/root/build-history-tab.tt +++ /dev/null @@ -1,73 +0,0 @@ -[% PROCESS common.tt %] -[% PROCESS "product-list.tt" %] -[% USE HTML %] -[% USE Date %] - - <h3>Build time history (in minutes)</h3> - - <div id="placeholder" style="width:800px;height:400px;"></div> - <div id="overview" style="margin-left:50px;margin-top:20px;width:600px;height:50px"></div> - - <script src="[% c.uri_for("/static/js/flot/jquery.flot.js") %]" type="text/javascript"></script> - <script src="[% c.uri_for("/static/js/flot/jquery.flot.selection.js") %]" type="text/javascript"></script> - <script type="text/javascript"> - $(function() { - var d = []; - var ids = []; - [% FOREACH prevbuild IN prevBuilds; IF prevbuild.build.starttime != 0 %] - d.push([[% prevbuild.starttime * 1000 %],[% prevbuild.get_column('actualBuildTime') / 60 %]]); - ids[[% prevbuild.starttime * 1000 %]] = [% prevbuild.id %] ; - [% END; END %] - - var options = { - xaxis: { mode: "time" }, - selection: { mode: "x" }, - points: { show: true }, - lines: { show: true }, - grid: { - clickable: true, - hoverable: true, - hoverFill: '#444', - hoverRadius: 4, - }, - }; - - - var plot = $.plot($("#placeholder"), [d], options); - - var overview = $.plot($("#overview"), [d], { - series: { - lines: { show: true, lineWidth: 1 }, - shadowSize: 0 - }, - xaxis: { ticks: [], mode: "time" }, - yaxis: { ticks: [], min: 0, autoscaleMargin: 0.1 }, - selection: { mode: "x" } - }); - - // now connect the two - - $("#placeholder").bind("plotselected", function (event, ranges) { - // do the zooming - plot = $.plot($("#placeholder"), [d], - $.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").bind("plotselected", function (event, ranges) { - plot.setSelection(ranges); - }); - - $("#placeholder").bind("plotclick", function (e, pos, item) { - if (item) { - plot.highlight(item.series, item.datapoint); - buildid = ids[item.datapoint[0]]; - window.location = "/build/"+buildid; - } - }); - }); - </script> diff --git a/src/root/build.tt b/src/root/build.tt index 4a5f4548..6159516e 100644 --- a/src/root/build.tt +++ b/src/root/build.tt @@ -103,7 +103,6 @@ <li><a href="#tabs-buildinputs" data-toggle="tab">Inputs</a></li> [% IF build.buildsteps %]<li><a href="#tabs-buildsteps" data-toggle="tab">Build steps</a></li>[% END %] [% IF build.dependents %]<li><a href="#tabs-usedby" data-toggle="tab">Used by</a></li>[% END%] - <li><a href="#tabs-history" data-toggle="tab">History chart</a></li> [% IF drvAvailable %]<li><a href="#tabs-build-deps" data-toggle="tab">Build dependencies</a></li>[% END %] [% IF available %]<li><a href="#tabs-runtime-deps" data-toggle="tab">Runtime dependencies</a></li>[% END %] </ul> @@ -408,8 +407,6 @@ </div> [% END %] - [% INCLUDE makeLazyTab tabName="tabs-history" uri=c.uri_for('/build' build.id 'history-graphs') %] - [% IF drvAvailable %] [% INCLUDE makeLazyTab tabName="tabs-build-deps" uri=c.uri_for('/build' build.id 'build-deps') %] [% END %] diff --git a/src/root/common.tt b/src/root/common.tt index 946c88ae..1ba51da7 100644 --- a/src/root/common.tt +++ b/src/root/common.tt @@ -549,7 +549,7 @@ BLOCK createChart %] data.forEach(function(x) { var t = x.timestamp * 1000; ids[t] = x.id; - d.push([t, x.value / (1024.0 * 1024.0)]); + d.push([t, x.value [% IF yaxis == "mib" %] / (1024.0 * 1024.0)[% END %]]); max = Math.max(t, max); }); diff --git a/src/root/job.tt b/src/root/job.tt index de2d2655..998bc083 100644 --- a/src/root/job.tt +++ b/src/root/job.tt @@ -86,13 +86,17 @@ removed or had an evaluation error.</div> <div id="tabs-charts" class="tab-pane"> + <h3>Build time (in seconds)</h3> + + [% INCLUDE createChart id="build-times" yaxis="sec" dataUrl=c.uri_for('/job' project.name jobset.name job.name 'build-times') %] + <h3>Closure size (in MiB)</h3> - [% INCLUDE createChart id="closure-size" dataUrl=c.uri_for('/job' project.name jobset.name job.name 'closure-sizes') %] + [% INCLUDE createChart id="closure-size" yaxis="mib" dataUrl=c.uri_for('/job' project.name jobset.name job.name 'closure-sizes') %] <h3>Output size (in MiB)</h3> - [% INCLUDE createChart id="output-size" dataUrl=c.uri_for('/job' project.name jobset.name job.name 'output-sizes') %] + [% INCLUDE createChart id="output-size" yaxis="mib" dataUrl=c.uri_for('/job' project.name jobset.name job.name 'output-sizes') %] </div>