Support days without any data in the history download.
authorPat Thoyts <Patrick.Thoyts@renishaw.com>
Wed, 28 Sep 2016 13:16:09 +0000 (14:16 +0100)
committerPat Thoyts <Patrick.Thoyts@renishaw.com>
Wed, 28 Sep 2016 13:16:09 +0000 (14:16 +0100)
If a day has no data then we cannot locate the oldest record so added
the date range in the response and we can use that instead.
This avoids getting stuck in the history download as we fetch 1 day at
a time.

sensor-hub.wsgi
static/sensor-hub.html

index 2f24f7aaab575b36b66f12ae73fc3b8ed10805d6..f439c7767969bf17440797b9bae3a9c0634e0e4c 100755 (executable)
@@ -80,7 +80,8 @@ class SensorHubService():
             else:
                 when_until = None
             data = self.get_since(when_from, when_until)
-            res = dict(response="ok", result=[x for x in data], version=self.version)
+            res = dict(response="ok", result=[x for x in data], version=self.version,
+                       range=[when_from, when_until])
         except Exception as e:
             cherrypy.response.headers['content-type'] = 'application/json'
             self.log("error in \"since\": {0}".format(str(e)))
index 401f1cc44392bf741fed6ce6b4985bcdcea63371..4ab2e950a0a3936877b2f1887bb0e391ac4cb2dd 100644 (file)
@@ -246,6 +246,9 @@ function add_data(data) {
             plotdata[n].push([t,v]);
         });
     });
+    //if data is empty we need to force 'oldest'
+    if (data.result.length == 0)
+        oldest = data.range[0]*1000;
     $.each(document.custom.plotdata, function(n,plot) {
        document.custom.plotdata[n].data = plotdata[n].concat(plot.data);
     });