[ARVADOS] updated: c8d0498d60f99c1564a68fb6f613875840ca270c

git at public.curoverse.com git at public.curoverse.com
Sun Nov 16 08:14:33 EST 2014


Summary of changes:
 apps/workbench/app/assets/javascripts/event_log.js | 72 ++++++++++++++++++----
 .../app/views/keep_disks/_content_layout.html.erb  |  3 -
 2 files changed, 59 insertions(+), 16 deletions(-)

       via  c8d0498d60f99c1564a68fb6f613875840ca270c (commit)
       via  05c6711bac76f5270a2979c9d2ff767a686797d5 (commit)
       via  f2cf5a532e7dee1ab68948db89272a0e2579e781 (commit)
      from  cb03f98d530626bc31c55acdcf6e60f9596fc759 (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 c8d0498d60f99c1564a68fb6f613875840ca270c
Author: Phil Hodgson <bitbucket at philhodgson.net>
Date:   Sun Nov 16 14:14:22 2014 +0100

    4233: will rescale y-axis for a series that scrolls off leaving less than fully scaled data points displaying on the chart

diff --git a/apps/workbench/app/assets/javascripts/event_log.js b/apps/workbench/app/assets/javascripts/event_log.js
index 0a7fc25..129c3a7 100644
--- a/apps/workbench/app/assets/javascripts/event_log.js
+++ b/apps/workbench/app/assets/javascripts/event_log.js
@@ -57,7 +57,11 @@ $(document).on('ajax:complete ready', function() {
     }
 });
 
-
+/* Assumes existence of:
+  window.jobGraphData = [];
+  window.jobGraphSeries = [];
+  window.jobGraphMaxima = {};
+ */
 function processLogLineForChart( logLine ) {
     var recreate = false;
     var rescale = false;
@@ -80,14 +84,9 @@ function processLogLineForChart( logLine ) {
         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
+            // set new maximum and rescale the series
             jobGraphMaxima[series] = datum;
-            // rescale
-            $.each( jobGraphData, function( i, entry ) {
-                if( entry[series] !== null && entry[series] !== undefined ) {
-                    entry[series] *= scaleConversion;
-                }
-            });
+            rescaleJobGraphSeries( series, scaleConversion );
         }
         // scale
         // FIXME: what about negative numbers?
@@ -112,16 +111,60 @@ function processLogLineForChart( logLine ) {
                 break;
             }
         }
+        // index counter from previous loop will have gone one too far, so add one
+        var insertAt = i+1;
         if(!found) {
-            i += 1;
+            // create a new x point for this previously unrecorded timestamp
             var entry = { 't': timestamp };
             entry[series] = scaledDatum;
-            jobGraphData.splice( i, 0, entry );
+            jobGraphData.splice( insertAt, 0, entry );
+            var shifted = [];
+            // now let's see about "scrolling" the graph, dropping entries that are too old (>3 minutes)
+            while( jobGraphData.length > 0
+                     && (Date.parse( jobGraphData[0]['t'] ).valueOf() + 3*60000 < Date.parse( jobGraphData[jobGraphData.length-1]['t'] ).valueOf()) ) {
+                shifted.push(jobGraphData.shift());
+            }
+            if( shifted.length > 0 ) {
+                // from those that we dropped, are any of them maxima? if so we need to rescale
+                jobGraphSeries.forEach( function(series) {
+                    // test that every shifted entry in this series was either not a number (in which case we don't care)
+                    // or else smaller than the scaled maximum (i.e. 1), because otherwise we just scrolled off something that was a maximum point
+                    // and so we need to recalculate a new maximum point by looking at all remaining displayed points in the series
+                    if( jobGraphMaxima[series] !== null
+                          && !shifted.every( function(e) { return( !($.isNumeric(e[series])) || e[series] < 1 ) } ) ) {
+                        // check the remaining displayed points and find the new (scaled) maximum
+                        var seriesMax = null;
+                        jobGraphData.forEach( function(entry) {
+                            if( $.isNumeric(entry[series]) && (seriesMax === null || entry[series] > seriesMax)) {
+                                seriesMax = entry[series];
+                            }
+                        });
+                        if( seriesMax !== null && seriesMax !== 0 ) {
+                            // set new actual maximum using the new maximum as the conversion conversion and rescale the series
+                            jobGraphMaxima[series] *= seriesMax;
+                            var scaleConversion = 1/seriesMax;
+                            rescaleJobGraphSeries( series, scaleConversion );
+                        }
+                        else {
+                            // we no longer have any data points displaying for this series
+                            jobGraphMaxima[series] = null;
+                        }
+                    }
+                });
+            }
         }
     }
     return recreate;
 }
 
+function rescaleJobGraphSeries( series, scaleConversion ) {
+    $.each( jobGraphData, function( i, entry ) {
+        if( entry[series] !== null && entry[series] !== undefined ) {
+            entry[series] *= scaleConversion;
+        }
+    });
+}
+
 $(document).on('arv-log-event', '#log_graph_div', function(event, eventData) {
     if( eventData.properties.text ) {
         var recreate = processLogLineForChart( eventData.properties.text );

commit 05c6711bac76f5270a2979c9d2ff767a686797d5
Author: Phil Hodgson <bitbucket at philhodgson.net>
Date:   Sun Nov 16 07:46:53 2014 +0100

    4233: remove explicit JS includes for showing Keep histogram now that they are in the general assets

diff --git a/apps/workbench/app/views/keep_disks/_content_layout.html.erb b/apps/workbench/app/views/keep_disks/_content_layout.html.erb
index 56177ae..2cf3291 100644
--- a/apps/workbench/app/views/keep_disks/_content_layout.html.erb
+++ b/apps/workbench/app/views/keep_disks/_content_layout.html.erb
@@ -1,8 +1,5 @@
 <% unless @histogram_pretty_date.nil? %>
   <% content_for :tab_panes do %>
-  <%# We use protocol-relative paths here to avoid browsers refusing to load javascript over http in a page that was loaded over https. %>
-  <%= javascript_include_tag '//cdnjs.cloudflare.com/ajax/libs/raphael/2.1.2/raphael-min.js' %>
-  <%= javascript_include_tag '//cdnjs.cloudflare.com/ajax/libs/morris.js/0.4.3/morris.min.js' %>
   <script type="text/javascript">
     $(document).ready(function(){
       $.renderHistogram(<%= raw @cache_age_histogram.to_json %>);

commit f2cf5a532e7dee1ab68948db89272a0e2579e781
Author: Phil Hodgson <bitbucket at philhodgson.net>
Date:   Sun Nov 16 07:45:55 2014 +0100

    4233: keep graph data array sorted by timestamp

diff --git a/apps/workbench/app/assets/javascripts/event_log.js b/apps/workbench/app/assets/javascripts/event_log.js
index 8f9728a..0a7fc25 100644
--- a/apps/workbench/app/assets/javascripts/event_log.js
+++ b/apps/workbench/app/assets/javascripts/event_log.js
@@ -102,18 +102,21 @@ function processLogLineForChart( logLine ) {
         var timestamp = preamble[0].replace('_','T');
         // identify x axis point
         var found = false;
-        for( var i = 0; i < jobGraphData.length; i++ ) {
+        for( var i = jobGraphData.length - 1; i >= 0; i-- ) {
             if( jobGraphData[i]['t'] === timestamp ) {
                 found = true;
+                jobGraphData[i][series] = scaledDatum;
+                break;
+            } else if( jobGraphData[i]['t'] < timestamp  ) {
+                // we've gone far enough back in time and this data is supposed to be sorted
                 break;
             }
         }
-        if(found) {
-            jobGraphData[i][series] = scaledDatum;
-        } else {
+        if(!found) {
+            i += 1;
             var entry = { 't': timestamp };
             entry[series] = scaledDatum;
-            jobGraphData.push( entry );
+            jobGraphData.splice( i, 0, entry );
         }
     }
     return recreate;

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list