Adjust context id variable names in the logbook processor to improve readability (#90617)

Adjust some variable names in the logbook process to improve readablity

There were some places were we used context_id that should have been context_id_bin
pull/90627/head^2
J. Nick Koston 2023-04-01 04:24:02 -10:00 committed by GitHub
parent e94c11371d
commit f1fa63281e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 9 deletions

View File

@ -204,7 +204,7 @@ def _humanify(
# Process rows
for row in rows:
context_id = context_lookup.memorize(row)
context_id_bin = context_lookup.memorize(row)
if row.context_only:
continue
event_type = row.event_type
@ -232,7 +232,7 @@ def _humanify(
if icon := row.icon or row.old_format_icon:
data[LOGBOOK_ENTRY_ICON] = icon
context_augmenter.augment(data, row, context_id)
context_augmenter.augment(data, row, context_id_bin)
yield data
elif event_type in external_events:
@ -240,7 +240,7 @@ def _humanify(
data = describe_event(event_cache.get(row))
data[LOGBOOK_ENTRY_WHEN] = format_time(row)
data[LOGBOOK_ENTRY_DOMAIN] = domain
context_augmenter.augment(data, row, context_id)
context_augmenter.augment(data, row, context_id_bin)
yield data
elif event_type == EVENT_LOGBOOK_ENTRY:
@ -259,7 +259,7 @@ def _humanify(
LOGBOOK_ENTRY_DOMAIN: entry_domain,
LOGBOOK_ENTRY_ENTITY_ID: entry_entity_id,
}
context_augmenter.augment(data, row, context_id)
context_augmenter.augment(data, row, context_id_bin)
yield data
@ -302,11 +302,11 @@ class ContextAugmenter:
self.include_entity_name = logbook_run.include_entity_name
def _get_context_row(
self, context_id: bytes | None, row: Row | EventAsRow
self, context_id_bin: bytes | None, row: Row | EventAsRow
) -> Row | EventAsRow | None:
"""Get the context row from the id or row context."""
if context_id:
return self.context_lookup.get(context_id)
if context_id_bin:
return self.context_lookup.get(context_id_bin)
if (context := getattr(row, "context", None)) is not None and (
origin_event := context.origin_event
) is not None:
@ -314,13 +314,13 @@ class ContextAugmenter:
return None
def augment(
self, data: dict[str, Any], row: Row | EventAsRow, context_id: bytes | None
self, data: dict[str, Any], row: Row | EventAsRow, context_id_bin: bytes | None
) -> None:
"""Augment data from the row and cache."""
if context_user_id_bin := row.context_user_id_bin:
data[CONTEXT_USER_ID] = bytes_to_uuid_hex_or_none(context_user_id_bin)
if not (context_row := self._get_context_row(context_id, row)):
if not (context_row := self._get_context_row(context_id_bin, row)):
return
if _rows_match(row, context_row):