Sampling data (aggregateWindow) for responsitivity + fixed old values not shown bug + readme
This commit is contained in:
@ -34,6 +34,16 @@ class InfluxGraph:
|
||||
self.lastvalues = {}
|
||||
self.variables = []
|
||||
|
||||
def seconds_to_nano(self, seconds):
|
||||
"""
|
||||
Converts seconds to nanoseconds
|
||||
Parameters:
|
||||
seconds (int)
|
||||
Returns :
|
||||
int
|
||||
"""
|
||||
return seconds*1000000000
|
||||
|
||||
def get_abs_time(self, times):
|
||||
"""
|
||||
Gets the absolute times for the given pontential relative times. If the given timestamps are less than one year, then the value is relative
|
||||
@ -82,7 +92,7 @@ class InfluxGraph:
|
||||
c.append((endtime, lastx))
|
||||
self.lastvalues[var] = (endtime, lastx)
|
||||
|
||||
def w_graph(self, variables, time="-1800,0"):
|
||||
def w_graph(self, variables, time="-1800,0", interval=None):
|
||||
"""
|
||||
Gets the curves given by variables in the time range "time"
|
||||
Called when the route /graph is reached.
|
||||
@ -90,6 +100,7 @@ class InfluxGraph:
|
||||
Parameters :
|
||||
variables (str) : a comma separataed value string of variable names (influx names) to retrieve
|
||||
time (str) : a commma separated value string (range) of seconds. They are treated as relative from now if they are lesser than one year.
|
||||
interval (str) : the interval (resolution) of the values to get (string in seconds)
|
||||
|
||||
Returns :
|
||||
{"type":"graph-draw", "reduced":(bool), "graph":{(str):[[(int),(float)]]}} : a dictionnary with its "graph-draw" type (so it can be processed by the client), a "reduced" value
|
||||
@ -104,8 +115,9 @@ class InfluxGraph:
|
||||
self.livemode = self.ACTUAL if end >= now else self.HISTORICAL
|
||||
logging.info('LIVE %g %g %d %d', end, now, end >= now, self.livemode)
|
||||
|
||||
result = self.influx_data_getter.get_curves_in_timerange(self.variables, self.time)
|
||||
|
||||
if interval : interval = self.seconds_to_nano(int(interval))
|
||||
result = self.influx_data_getter.get_curves_in_timerange(self.variables, self.time, interval)
|
||||
|
||||
self.strip_future(result)
|
||||
self.complete_to_end(result, end)
|
||||
self.time[0] = self.time[1]
|
||||
|
Reference in New Issue
Block a user