diff --git a/src/laminar.cpp b/src/laminar.cpp index f7fd9da..fb5e229 100644 --- a/src/laminar.cpp +++ b/src/laminar.cpp @@ -229,9 +229,10 @@ void Laminar::sendStatus(LaminarClient* client) { .EndObject(); }); j.EndArray(); - db->stmt("SELECT COUNT(*) FROM builds WHERE name = ?") + db->stmt("SELECT COUNT(*),AVG(completedAt-startedAt) FROM builds WHERE name = ?") .bind(client->scope.job) - .fetch([&](uint nRuns){ + .fetch([&](uint nRuns, uint averageRuntime){ + j.set("averageRuntime", averageRuntime); j.set("pages", (nRuns-1) / runsPerPage + 1); j.startObject("sort"); j.set("page", client->scope.page) diff --git a/src/resources/js/app.js b/src/resources/js/app.js index 08af265..f233987 100644 --- a/src/resources/js/app.js +++ b/src/resources/js/app.js @@ -501,6 +501,16 @@ var Job = function() { return '#' + e.number; }).reverse(), datasets: [{ + label: 'Average', + type: 'line', + data: [{x:0,y:msg.averageRuntime},{x:1,y:msg.averageRuntime}], + borderColor: 'steelblue', + backgroundColor: 'transparent', + xAxisID: 'avg', + pointRadius: 0, + pointHitRadius: 0, + pointHoverRadius: 0, + },{ label: 'Build time', backgroundColor: (new Array(msg.recent.length)).fill('darkseagreen'), borderColor: (new Array(msg.recent.length)).fill('forestgreen'), @@ -508,6 +518,21 @@ var Job = function() { return e.completed - e.started; }).reverse() }] + }, + options: { + scales:{ + xAxes:[{},{ + id: 'avg', + type: 'linear', + ticks: { + display: false + }, + gridLines: { + display: false, + drawBorder: false + } + }] + } } });