[ARVADOS] updated: cb03f98d530626bc31c55acdcf6e60f9596fc759
git at public.curoverse.com
git at public.curoverse.com
Sat Nov 15 09:17:47 EST 2014
Summary of changes:
apps/workbench/app/assets/javascripts/event_log.js | 54 +++++++++++++++++-----
apps/workbench/app/views/jobs/_show_log.html.erb | 9 ++--
2 files changed, 48 insertions(+), 15 deletions(-)
via cb03f98d530626bc31c55acdcf6e60f9596fc759 (commit)
via 768f5281784b419e4d5617cb34e89298d1899a59 (commit)
from bce765931ead12469cb1d363a7974c3380191df6 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit cb03f98d530626bc31c55acdcf6e60f9596fc759
Author: Phil Hodgson <bitbucket at philhodgson.net>
Date: Sat Nov 15 15:16:51 2014 +0100
4233: now the y-axis series will scale to always be between 0 and 1
diff --git a/apps/workbench/app/assets/javascripts/event_log.js b/apps/workbench/app/assets/javascripts/event_log.js
index 77ed7bf..8f9728a 100644
--- a/apps/workbench/app/assets/javascripts/event_log.js
+++ b/apps/workbench/app/assets/javascripts/event_log.js
@@ -59,12 +59,16 @@ $(document).on('ajax:complete ready', function() {
function processLogLineForChart( logLine ) {
+ var recreate = false;
+ var rescale = false;
// TODO: make this more robust: anything could go wrong in here
var match = logLine.match(/(.*)crunchstat:(.*)-- interval(.*)/);
if( match ) {
var series = match[2].trim().split(' ')[0];
if( $.inArray( series, jobGraphSeries) < 0 ) {
jobGraphSeries.push(series);
+ jobGraphMaxima[series] = null;
+ recreate = true;
}
var intervalData = match[3].trim().split(' ');
var dt = parseFloat(intervalData[0]);
@@ -72,27 +76,53 @@ function processLogLineForChart( logLine ) {
for(var i=2; i < intervalData.length; i += 2 ) {
dsum += parseFloat(intervalData[i]);
}
- // TODO: why 4? what if the data is smaller than 0.0001?
- var datum = (dsum/dt).toFixed(4);
+ var datum = dsum/dt;
+ if( datum !== 0 && ( jobGraphMaxima[series] === null || jobGraphMaxima[series] < datum ) ) {
+ // use old maximum to get a scale conversion
+ var scaleConversion = jobGraphMaxima[series]/datum;
+ // set new maximum
+ jobGraphMaxima[series] = datum;
+ // rescale
+ $.each( jobGraphData, function( i, entry ) {
+ if( entry[series] !== null && entry[series] !== undefined ) {
+ entry[series] *= scaleConversion;
+ }
+ });
+ }
+ // scale
+ // FIXME: what about negative numbers?
+ var scaledDatum = null;
+ if( jobGraphMaxima[series] !== null && jobGraphMaxima[series] !== 0 ) {
+ scaledDatum = datum/jobGraphMaxima[series]
+ } else {
+ scaledDatum = datum;
+ }
+ // more parsing
var preamble = match[1].trim().split(' ');
var timestamp = preamble[0].replace('_','T');
- var xpoints = $.grep( jobGraphData, function(e){ return e['t'] === timestamp; });
- if(xpoints.length) {
- // xpoints[0] is the x point that that matched the timestamp and so already existed: add the new datum
- xpoints[0][series] = datum;
+ // identify x axis point
+ var found = false;
+ for( var i = 0; i < jobGraphData.length; i++ ) {
+ if( jobGraphData[i]['t'] === timestamp ) {
+ found = true;
+ break;
+ }
+ }
+ if(found) {
+ jobGraphData[i][series] = scaledDatum;
} else {
var entry = { 't': timestamp };
- entry[series] = datum;
+ entry[series] = scaledDatum;
jobGraphData.push( entry );
}
}
+ return recreate;
}
$(document).on('arv-log-event', '#log_graph_div', function(event, eventData) {
if( eventData.properties.text ) {
- var series_length = jobGraphSeries.length;
- processLogLineForChart( eventData.properties.text );
- if( series_length < jobGraphSeries.length) {
+ var recreate = processLogLineForChart( eventData.properties.text );
+ if( recreate ) {
// series have changed, draw entirely new graph
$('#log_graph_div').html('');
window.jobGraph = Morris.Line({
diff --git a/apps/workbench/app/views/jobs/_show_log.html.erb b/apps/workbench/app/views/jobs/_show_log.html.erb
index efe6df4..625642b 100644
--- a/apps/workbench/app/views/jobs/_show_log.html.erb
+++ b/apps/workbench/app/views/jobs/_show_log.html.erb
@@ -20,6 +20,7 @@
<%= javascript_tag do %>
window.jobGraphData = [];
window.jobGraphSeries = [];
+ window.jobGraphMaxima = {};
<% stderr_log_records([@object.uuid],[['properties','~','crunchstat:.*-- interval']])
.each.with_index do |log_record, index| %>
var logLine = '<%=j log_record.properties[:text] %>';
commit 768f5281784b419e4d5617cb34e89298d1899a59
Author: Phil Hodgson <bitbucket at philhodgson.net>
Date: Sat Nov 15 14:26:52 2014 +0100
4233: why pass around global variables?
diff --git a/apps/workbench/app/assets/javascripts/event_log.js b/apps/workbench/app/assets/javascripts/event_log.js
index 10fe5be..77ed7bf 100644
--- a/apps/workbench/app/assets/javascripts/event_log.js
+++ b/apps/workbench/app/assets/javascripts/event_log.js
@@ -58,7 +58,8 @@ $(document).on('ajax:complete ready', function() {
});
-function processLogLineForChart( logLine, jobGraphSeries, jobGraphData ) {
+function processLogLineForChart( logLine ) {
+ // TODO: make this more robust: anything could go wrong in here
var match = logLine.match(/(.*)crunchstat:(.*)-- interval(.*)/);
if( match ) {
var series = match[2].trim().split(' ')[0];
@@ -71,6 +72,7 @@ function processLogLineForChart( logLine, jobGraphSeries, jobGraphData ) {
for(var i=2; i < intervalData.length; i += 2 ) {
dsum += parseFloat(intervalData[i]);
}
+ // TODO: why 4? what if the data is smaller than 0.0001?
var datum = (dsum/dt).toFixed(4);
var preamble = match[1].trim().split(' ');
var timestamp = preamble[0].replace('_','T');
@@ -89,11 +91,11 @@ function processLogLineForChart( logLine, jobGraphSeries, jobGraphData ) {
$(document).on('arv-log-event', '#log_graph_div', function(event, eventData) {
if( eventData.properties.text ) {
var series_length = jobGraphSeries.length;
- processLogLineForChart( eventData.properties.text, jobGraphSeries, jobGraphData);
+ processLogLineForChart( eventData.properties.text );
if( series_length < jobGraphSeries.length) {
// series have changed, draw entirely new graph
$('#log_graph_div').html('');
- jobGraph = Morris.Line({
+ window.jobGraph = Morris.Line({
element: 'log_graph_div',
data: jobGraphData,
xkey: 't',
diff --git a/apps/workbench/app/views/jobs/_show_log.html.erb b/apps/workbench/app/views/jobs/_show_log.html.erb
index 75edf59..efe6df4 100644
--- a/apps/workbench/app/views/jobs/_show_log.html.erb
+++ b/apps/workbench/app/views/jobs/_show_log.html.erb
@@ -18,14 +18,14 @@
></div>
<%= javascript_tag do %>
- var jobGraphData = [];
- var jobGraphSeries = [];
+ window.jobGraphData = [];
+ window.jobGraphSeries = [];
<% stderr_log_records([@object.uuid],[['properties','~','crunchstat:.*-- interval']])
.each.with_index do |log_record, index| %>
var logLine = '<%=j log_record.properties[:text] %>';
- processLogLineForChart( logLine, jobGraphSeries, jobGraphData );
+ processLogLineForChart( logLine );
<% end %>
- var jobGraph = Morris.Line({
+ window.jobGraph = Morris.Line({
element: 'log_graph_div',
data: jobGraphData,
xkey: 't',
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list