Skip to content

Commit

Permalink
Updated query for fetching the "latest data timestamp" from InfluxDB …
Browse files Browse the repository at this point in the history
…to ensure better performance for larger datasets
  • Loading branch information
Martin committed Oct 18, 2021
1 parent 8c5cb8d commit b9907cc
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion dashboard-writer/utils_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def get_start_times(self, devices, default_start, dynamic):
elif self.test != 0:
for device in device_ids:
influx_time = self.client.query_api().query(
f'from(bucket:"{self.influx_bucket}") |> range(start: 0, stop: now()) |> filter(fn: (r) => r["_measurement"] == "{device}") |> keep(columns: ["_time"]) |> sort(columns: ["_time"], desc: false) |> last(column: "_time")'
f'from(bucket:"{self.influx_bucket}") |> range(start: -100d) |> filter(fn: (r) => r["_measurement"] == "{device}") |> group() |> last()'
)

if len(influx_time) == 0:
Expand Down

0 comments on commit b9907cc

Please sign in to comment.