sheetsync: Convey row parent info

by prefixing with a number of ^ characters and noting the parent id in the notes column.
pull/401/head
Mike Lang 3 months ago
parent 23960d947b
commit 760dbd1e07

@ -126,8 +126,14 @@ class StreamLogEventsMiddleware(Middleware):
def get_rows(self): def get_rows(self):
all_rows = [] all_rows = []
for row in self.client.get_entries()["event_log"]: entries_by_id = {}
row = self.parse_row(row) for entry in self.client.get_entries()["event_log"]:
# Keep track of how many levels of sub-entry each entry is
entries_by_id[entry["id"]] = entry
parent = entry["parent"]
entry["depth"] = 0 if parent is None else entries_by_id[parent]["depth"] + 1
row = self.parse_row(entry)
# Malformed rows can be skipped, represented as a None result # Malformed rows can be skipped, represented as a None result
if row is not None: if row is not None:
all_rows.append(row) all_rows.append(row)
@ -157,6 +163,12 @@ class StreamLogEventsMiddleware(Middleware):
if output["poster_moment"]: if output["poster_moment"]:
output['tags'] += 'Poster Moment' output['tags'] += 'Poster Moment'
# Convey parent info
if row["depth"] > 0:
output["description"] = "^" * row["depth"] + " " + output["description"]
pre_note = f"Part of event {output['parent']}"
output["notes"] = f"{pre_note}. {output['notes']}" if output["notes"] else pre_note
return output return output
def write_value(self, row, key, value): def write_value(self, row, key, value):

Loading…
Cancel
Save