From 9b64028138fd16ed71b1d5f45d509dc9234d06f7 Mon Sep 17 00:00:00 2001 From: Robert Goldmann <deadlocker@gmx.de> Date: Sat, 2 Jan 2021 11:36:48 +0100 Subject: [PATCH] #36 - prevent fetching min/max from StorageLeaf as this would consume a lot of time due to huge timespans --- src/logic/tile/tiles/SensorLineChartTile.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/logic/tile/tiles/SensorLineChartTile.py b/src/logic/tile/tiles/SensorLineChartTile.py index 26da0e0..6e070c1 100644 --- a/src/logic/tile/tiles/SensorLineChartTile.py +++ b/src/logic/tile/tiles/SensorLineChartTile.py @@ -74,7 +74,8 @@ class SensorLineChartTile(Tile): sensorData['sensorInfo']['type'], startDateTime, endDateTime, - storageLeafService) + storageLeafService, + y) # Check if all values are above zero and the min value for the sensor group is below zero. # Therefore a ghost trace must be generated that fills the area underneath the x-axis. @@ -98,10 +99,18 @@ class SensorLineChartTile(Tile): def __get_min_and_max(self, pageName: str, sensorType: Dict, startDateTime: str, endDateTime: str, - storageLeafService: MultiCacheKeyService): + storageLeafService: MultiCacheKeyService, y: List): if sensorType == SensorType.HUMIDITY: return 0, 100 + # prevent fetching min/max from StorageLeaf as this would consume a lot of time due to huge timespans + if self._settings['showAxes']: + yValues = [float(item) for item in y] + if yValues: + return min(0.0, min(yValues)), max(yValues) + self.MAX_Y_AXIS_SPACING + else: + return 0, 0 + self.MAX_Y_AXIS_SPACING + minMaxSettings = { 'url': self._settings['url'], 'sensorIDsForMinMax': self._settings['sensorIDsForMinMax'], -- GitLab