Skip to content

Commit

Permalink
Merge branch '0.8.9' of github.com:m4dm4rtig4n/myelectricaldata into …
Browse files Browse the repository at this point in the history
…0.8.9
  • Loading branch information
m4dm4rtig4n committed Dec 11, 2022
2 parents 5831886 + 730af78 commit 623f7d6
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions app/models/influxdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,19 @@ def purge_influxdb(self):
app.LOG.warning(f" => Data reset")

def get_list_retention_policies(self):
buckets = self.buckets_api.find_buckets().buckets
for bucket in buckets:
if bucket.name == self.bucket:
self.retention = bucket.retention_rules[0].every_seconds
self.max_retention = datetime.datetime.now() - datetime.timedelta(seconds=self.retention)
if self.org == f"-": # InfluxDB 1.8
self.retention = 0
self.max_retention = 0
return
else:
buckets = self.buckets_api.find_buckets().buckets
for bucket in buckets:
if bucket.name == self.bucket:
self.retention = bucket.retention_rules[0].every_seconds
self.max_retention = datetime.datetime.now() - datetime.timedelta(seconds=self.retention)

def write(self, tags, date=None, fields=None, measurement="log"):
date_max = datetime.datetime.now() - datetime.timedelta(seconds=self.retention)
date_max = self.max_retention
if date is None:
date_object = datetime.datetime.now()
else:
Expand Down

0 comments on commit 623f7d6

Please sign in to comment.