257 files
This commit is contained in:
@@ -102,6 +102,10 @@ class MaintenanceTask:
|
||||
# (manual | auto | object) and drives the auto-delete + object-cascade rules.
|
||||
archived_at: str | None = None
|
||||
archived_reason: str | None = None
|
||||
# #193: a pause for this one task (the object's pause, per task):
|
||||
# paused_at set = paused; paused_until (ISO date) optionally ends it.
|
||||
paused_at: str | None = None
|
||||
paused_until: str | None = None
|
||||
|
||||
# --- User Assignment ---
|
||||
responsible_user_id: str | None = None # HA user UUID (current pointer)
|
||||
@@ -293,13 +297,12 @@ class MaintenanceTask:
|
||||
|
||||
@property
|
||||
def total_cost(self) -> float:
|
||||
"""Sum of all costs in history."""
|
||||
total = 0.0
|
||||
for entry in self.history:
|
||||
cost = finite_amount(entry.get("cost")) if isinstance(entry, dict) else None
|
||||
if cost is not None:
|
||||
total += cost
|
||||
return total
|
||||
"""What this task's history counts as spending (#104: a completion
|
||||
booked "when used" counts its parts, a purchase booked so counts
|
||||
nothing — helpers.parts_cost.entry_spend decides for every total)."""
|
||||
from ..helpers.parts_cost import entry_spend
|
||||
|
||||
return sum(entry_spend(entry, finite_amount) for entry in self.history if isinstance(entry, dict))
|
||||
|
||||
@property
|
||||
def average_duration(self) -> float | None:
|
||||
@@ -671,6 +674,10 @@ class MaintenanceTask:
|
||||
data["archived_at"] = self.archived_at
|
||||
if self.archived_reason is not None:
|
||||
data["archived_reason"] = self.archived_reason
|
||||
if self.paused_at is not None:
|
||||
data["paused_at"] = self.paused_at
|
||||
if self.paused_until is not None:
|
||||
data["paused_until"] = self.paused_until
|
||||
if self.responsible_user_id is not None:
|
||||
data["responsible_user_id"] = self.responsible_user_id
|
||||
if self.assignee_pool:
|
||||
@@ -735,6 +742,8 @@ class MaintenanceTask:
|
||||
mirror_todo_entities=list(data.get("mirror_todo_entities") or []),
|
||||
archived_at=data.get("archived_at"),
|
||||
archived_reason=data.get("archived_reason"),
|
||||
paused_at=data.get("paused_at"),
|
||||
paused_until=data.get("paused_until"),
|
||||
responsible_user_id=data.get("responsible_user_id"),
|
||||
assignee_pool=data.get("assignee_pool", []),
|
||||
rotation_strategy=data.get("rotation_strategy"),
|
||||
|
||||
Reference in New Issue
Block a user