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):
all_rows = []
for row in self.client.get_entries()["event_log"]:
row = self.parse_row(row)
entries_by_id = {}
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
if row is not None:
all_rows.append(row)
@ -157,6 +163,12 @@ class StreamLogEventsMiddleware(Middleware):
if output["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
def write_value(self, row, key, value):

Loading…
Cancel
Save