Reduce number of columns selected for logbook (#91718)

This commit is contained in:
J. Nick Koston 2023-04-22 07:25:22 -05:00 committed by GitHub
parent 34b824a27b
commit b76551cf35
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 20 additions and 33 deletions

View file

@ -71,7 +71,7 @@ class LazyEventPartialState:
# json decode process as we already have the data
self.data = row.data
return
source = cast(str, self.row.shared_data or self.row.event_data)
source = cast(str, self.row.event_data)
if not source:
self.data = {}
elif event_data := self._event_data_cache.get(source):
@ -105,17 +105,14 @@ class EventAsRow:
context: Context
context_id_bin: bytes
time_fired_ts: float
state_id: int
row_id: int
event_data: str | None = None
old_format_icon: None = None
event_id: None = None
entity_id: str | None = None
icon: str | None = None
context_user_id_bin: bytes | None = None
context_parent_id_bin: bytes | None = None
event_type: str | None = None
state: str | None = None
shared_data: str | None = None
context_only: None = None
@ -132,7 +129,7 @@ def async_event_to_row(event: Event) -> EventAsRow:
context_user_id_bin=uuid_hex_to_bytes_or_none(context.user_id),
context_parent_id_bin=ulid_to_bytes_or_none(context.parent_id),
time_fired_ts=dt_util.utc_to_timestamp(event.time_fired),
state_id=hash(event),
row_id=hash(event),
)
# States are prefiltered so we never get states
# that are missing new_state or old_state
@ -148,6 +145,6 @@ def async_event_to_row(event: Event) -> EventAsRow:
context_user_id_bin=uuid_hex_to_bytes_or_none(context.user_id),
context_parent_id_bin=ulid_to_bytes_or_none(context.parent_id),
time_fired_ts=dt_util.utc_to_timestamp(new_state.last_updated),
state_id=hash(event),
row_id=hash(event),
icon=new_state.attributes.get(ATTR_ICON),
)