fixed multible_read for django db and added write to django db as default temporary
This commit is contained in:
parent
b2014e23be
commit
327fd9c5f1
|
|
@ -117,10 +117,6 @@ class InfluxDatabase(models.Model):
|
|||
|
||||
|
||||
def read_multiple(self, **kwargs):
|
||||
if self.only_write_to_influxdb:
|
||||
django_database = self.get_django_database()
|
||||
return django_database.read_multiple(**kwargs)
|
||||
|
||||
variable_ids = kwargs.pop("variable_ids") if "variable_ids" in kwargs else []
|
||||
time_min = kwargs.pop("time_min") if "time_min" in kwargs else 0
|
||||
time_max = kwargs.pop("time_max") if "time_max" in kwargs else time.time()
|
||||
|
|
@ -141,7 +137,15 @@ class InfluxDatabase(models.Model):
|
|||
f_time_scale = 1000
|
||||
else:
|
||||
f_time_scale = 1
|
||||
|
||||
if self.only_write_to_influxdb:
|
||||
return self.get_django_database()._import_model().objects.db_data(
|
||||
variable_ids=variable_ids,
|
||||
time_min=time_min,
|
||||
time_max=time_max,
|
||||
time_in_ms=time_in_ms,
|
||||
query_first_value=query_first_value,
|
||||
**kwargs,
|
||||
)
|
||||
values = {}
|
||||
query_api = self.get_query_api()
|
||||
tmp_time_max = time_min*f_time_scale
|
||||
|
|
@ -164,7 +168,7 @@ class InfluxDatabase(models.Model):
|
|||
return values
|
||||
|
||||
def write_multiple(self, **kwargs):
|
||||
if self.only_write_to_influxdb:
|
||||
if self.only_write_to_influxdb or True:
|
||||
django_database = self.get_django_database()
|
||||
data_model = django_database._import_model()
|
||||
|
||||
|
|
@ -186,7 +190,7 @@ class InfluxDatabase(models.Model):
|
|||
point = self.create_data_element_from_variable(
|
||||
item, cached_value[1], cached_value[0], **kwargs
|
||||
)
|
||||
if self.only_write_to_influxdb:
|
||||
if self.only_write_to_influxdb or True:
|
||||
rc = data_model.objects.create_data_element_from_variable(
|
||||
item, cached_value[0], cached_value[0], **kwargs
|
||||
)
|
||||
|
|
@ -204,7 +208,7 @@ class InfluxDatabase(models.Model):
|
|||
self.write_points(points)
|
||||
points = []
|
||||
|
||||
if self.only_write_to_influxdb:
|
||||
if self.only_write_to_influxdb or True:
|
||||
try:
|
||||
data_model.objects.bulk_create(recordings, batch_size=batch_size, **kwargs)
|
||||
except IntegrityError:
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user