fix ux
This commit is contained in:
@@ -104,7 +104,7 @@ class EnergyService:
|
||||
return rows
|
||||
|
||||
def bucketize_daily(self, records: list[DailyEnergyRecord], bucket: str) -> list[BucketPoint]:
|
||||
grouped: dict[str, dict] = defaultdict(lambda: {"value": 0.0, "start": None, "end": None, "label": ""})
|
||||
grouped: dict[str, dict] = defaultdict(lambda: {"value": 0.0, "start": None, "end": None, "label": "", "has_data": False})
|
||||
|
||||
for record in records:
|
||||
start = datetime.combine(record.day, time.min, tzinfo=self.tz)
|
||||
@@ -137,7 +137,9 @@ class EnergyService:
|
||||
|
||||
current = grouped[key]
|
||||
current["label"] = label
|
||||
current["value"] += record.energy_kwh
|
||||
if record.samples_count > 0:
|
||||
current["value"] += record.energy_kwh
|
||||
current["has_data"] = True
|
||||
current["start"] = bucket_start if current["start"] is None else min(current["start"], bucket_start)
|
||||
current["end"] = bucket_end if current["end"] is None else max(current["end"], bucket_end)
|
||||
|
||||
@@ -149,7 +151,7 @@ class EnergyService:
|
||||
label=item["label"],
|
||||
start=item["start"],
|
||||
end=item["end"],
|
||||
value=round(item["value"], 2),
|
||||
value=round(item["value"], 2) if item["has_data"] else None,
|
||||
)
|
||||
)
|
||||
return rows
|
||||
|
||||
Reference in New Issue
Block a user