Record state.last_reported (#114201)
* Record state.last_reported * Include last_reported in parts of the history API * Use a bulk update * fix refactoring error --------- Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
parent
24168dfba7
commit
a3059fe504
13 changed files with 225 additions and 23 deletions
|
@ -81,6 +81,18 @@ class LazyState(State):
|
|||
self._last_changed_ts or self._last_updated_ts
|
||||
)
|
||||
|
||||
@cached_property
|
||||
def _last_reported_ts(self) -> float | None:
|
||||
"""Last reported timestamp."""
|
||||
return getattr(self._row, "last_reported_ts", None)
|
||||
|
||||
@cached_property
|
||||
def last_reported(self) -> datetime: # type: ignore[override]
|
||||
"""Last reported datetime."""
|
||||
return dt_util.utc_from_timestamp(
|
||||
self._last_reported_ts or self._last_updated_ts
|
||||
)
|
||||
|
||||
@cached_property
|
||||
def last_updated(self) -> datetime: # type: ignore[override]
|
||||
"""Last updated datetime."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue