From ced540ac5092f717fd1e7ad900ee5be0a6a0288c Mon Sep 17 00:00:00 2001 From: Pat Thoyts Date: Wed, 28 Sep 2016 14:16:09 +0100 Subject: [PATCH] Support days without any data in the history download. 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 | 3 ++- static/sensor-hub.html | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/sensor-hub.wsgi b/sensor-hub.wsgi index 2f24f7a..f439c77 100755 --- a/sensor-hub.wsgi +++ b/sensor-hub.wsgi @@ -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))) diff --git a/static/sensor-hub.html b/static/sensor-hub.html index 401f1cc..4ab2e95 100644 --- a/static/sensor-hub.html +++ b/static/sensor-hub.html @@ -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); }); -- 2.23.0