Removed all curves at given day
This commit is contained in:
28
influxdb.py
28
influxdb.py
@@ -53,7 +53,7 @@ class InfluxDataGetter:
|
||||
|
||||
# ----- PUBLIC METHODS
|
||||
|
||||
def get_available_variables_at_time(self, times, all=False):
|
||||
def get_available_variables_at_time(self, times):
|
||||
"""
|
||||
Gets the available variables (those that we can have a value for since the device has been installed on the instrument) at the given point in time.
|
||||
We can get the last available variables at the given point in time or all the known variables for the day corresponding to the timestamp.
|
||||
@@ -67,7 +67,7 @@ class InfluxDataGetter:
|
||||
a block of curves with their name, their label and their color to display, grouped by their tag (which can be the unit augmented with an index) and their unit.
|
||||
"""
|
||||
|
||||
all_setup_info = self._get_all_setup_info_as_dict(times, all)
|
||||
all_setup_info = self._get_all_setup_info_as_dict(times)
|
||||
available_variables = self._extract_variables(all_setup_info)
|
||||
available_variables = self._remove_variables_without_value_float(available_variables, times)
|
||||
available_variables = self._set_variables_with_target(available_variables, times)
|
||||
@@ -75,7 +75,7 @@ class InfluxDataGetter:
|
||||
|
||||
return res
|
||||
|
||||
def get_available_variables_at_time2(self, times, all=False):
|
||||
def get_available_variables_at_time2(self, times):
|
||||
"""
|
||||
Gets the available variables (those that we can have a value for since the device has been installed on the instrument) at the given point in time.
|
||||
We can get the last available variables at the given point in time or all the known variables for the day corresponding to the timestamp.
|
||||
@@ -89,7 +89,7 @@ class InfluxDataGetter:
|
||||
a block of curves with their name, their label and their color to display, grouped by their tag (which can be the unit augmented with an index) and their unit.
|
||||
"""
|
||||
|
||||
all_setup_info = self._get_all_setup_info_as_dict(times, all)
|
||||
all_setup_info = self._get_all_setup_info_as_dict(times)
|
||||
|
||||
available_variables = self._extract_variables2(all_setup_info)
|
||||
available_variables = self._filter_params_with_config(available_variables)
|
||||
@@ -214,14 +214,13 @@ class InfluxDataGetter:
|
||||
|
||||
# ----- PRIVATE METHODS
|
||||
|
||||
def _get_all_setup_info_as_dict(self, times, all=False):
|
||||
def _get_all_setup_info_as_dict(self, times):
|
||||
"""
|
||||
Gets the value of the field setup_info in the measurements nicos/se_main, nicos/se_stick, nicos/se_addons as an array of Python dicts.
|
||||
Takes the last setup_info dict (for each measurement) known at times[1], or all the dicts for this day + the previous known (also for each)
|
||||
|
||||
Parameters
|
||||
times ([int]) : the unix timestamps in seconds of the range. The first value can be unused. The last can represent the point in time.
|
||||
all (bool) : indicates if we want all the variables for the given times[1] timestamp (all the day)
|
||||
|
||||
Returns :
|
||||
[{(str):((str), {...})}]: an array of the parsed "setup_info dict" of each measurements. The key is the secop_module prefixed with "se_", and the value is a tuple with its first value
|
||||
@@ -234,10 +233,10 @@ class InfluxDataGetter:
|
||||
to_add = []
|
||||
query = f"""
|
||||
from(bucket: "{self._bucket}")
|
||||
|> range(start: {times[0] if all=="True" else 0}, stop: {times[1] + 1})
|
||||
|> range(start: 0, stop: {times[1] + 1})
|
||||
|> filter(fn: (r) => r._measurement == "{measurement}")
|
||||
|> filter(fn: (r) => r._field == "setup_info")
|
||||
{"" if all=="True" else "|> last()"}
|
||||
|> last()
|
||||
|> yield(name: "res")
|
||||
"""
|
||||
tables = self._db.query(query)
|
||||
@@ -245,19 +244,6 @@ class InfluxDataGetter:
|
||||
for record in table.records:
|
||||
to_add.append(ast.literal_eval(record.get_value()))
|
||||
|
||||
if all == "True":
|
||||
query = f"""
|
||||
from(bucket: "{self._bucket}")
|
||||
|> range(start: 0, stop: {times[0]+1})
|
||||
|> filter(fn: (r) => r._measurement == "{measurement}")
|
||||
|> filter(fn: (r) => r._field == "setup_info")
|
||||
|> last()
|
||||
|> yield(name: "res")
|
||||
"""
|
||||
tables = self._db.query(query)
|
||||
for table in tables:
|
||||
for record in table.records:
|
||||
to_add.append(ast.literal_eval(record.get_value()))
|
||||
res.extend(to_add)
|
||||
return res
|
||||
|
||||
|
||||
Reference in New Issue
Block a user