Reduce indent in recorder event processing (#69659)

This commit is contained in:
J. Nick Koston 2022-04-07 23:37:20 -10:00 committed by GitHub
parent 72fffde77a
commit 5076437413
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1154,7 +1154,9 @@ class Recorder(threading.Thread):
return
self.event_session.add(dbevent)
if event.event_type == EVENT_STATE_CHANGED:
if event.event_type != EVENT_STATE_CHANGED:
return
try:
dbstate = States.from_event(event)
shared_attrs = StateAttributes.shared_attrs_from_event(
@ -1179,9 +1181,7 @@ class Recorder(threading.Thread):
attr_hash = StateAttributes.hash_shared_attrs(shared_attrs)
# Matching attributes found in the database
if (
attributes := self.event_session.query(
StateAttributes.attributes_id
)
attributes := self.event_session.query(StateAttributes.attributes_id)
.filter(StateAttributes.hash == attr_hash)
.filter(StateAttributes.shared_attrs == shared_attrs)
.first()