sheetsync: Always have sheet name as part of row dict

pull/401/head
Mike Lang 1 year ago committed by Mike Lang
parent fa9a4b70bb
commit eec58f2651

@ -107,7 +107,7 @@ class SheetSync(object):
worksheets = self.middleware.pick_worksheets() worksheets = self.middleware.pick_worksheets()
for worksheet in worksheets: for worksheet in worksheets:
for row in self.middleware.get_rows(worksheet): for row in self.middleware.get_rows(worksheet):
self.sync_row(worksheet, row, events.get(row['id'])) self.sync_row(row, events.get(row['id']))
except Exception as e: except Exception as e:
# for HTTPErrors, http response body includes the more detailed error # for HTTPErrors, http response body includes the more detailed error
@ -152,9 +152,10 @@ class SheetSync(object):
event_counts.labels(*labels).set(count) event_counts.labels(*labels).set(count)
return by_id return by_id
def sync_row(self, worksheet, row, event): def sync_row(self, row, event):
"""Take a row dict and an Event from the database (or None if id not found) """Take a row dict and an Event from the database (or None if id not found)
and take whatever action is required to sync them, ie. writing to the database or sheet.""" and take whatever action is required to sync them, ie. writing to the database or sheet."""
worksheet = row["sheet_name"]
if event is None: if event is None:
# No event currently in DB, create it. # No event currently in DB, create it.

@ -227,8 +227,9 @@ class SheetsMiddleware():
# As a special case, treat an end time of "--" as equal to the start time. # As a special case, treat an end time of "--" as equal to the start time.
if row_dict["event_end"] == "--": if row_dict["event_end"] == "--":
row_dict["event_end"] = row_dict["event_start"] row_dict["event_end"] = row_dict["event_start"]
# Always include row index # Always include row index and worksheet
row_dict["index"] = row_index row_dict["index"] = row_index
row_dict["sheet_name"] = worksheet
return row_dict return row_dict
def write_value(self, worksheet, row, key, value): def write_value(self, worksheet, row, key, value):

@ -88,10 +88,13 @@ class StreamLogMiddleware:
value = self.column_decode[column](value) value = self.column_decode[column](value)
output[column] = value output[column] = value
# Section name is sheet name
output["sheet_name"] = row["section"]["name"]
# Implicit tags # Implicit tags
output['tags'] += [ output['tags'] += [
output['category'], output['category'],
row['section']['name'], output["sheet_name"],
] ]
if output["poster_moment"]: if output["poster_moment"]:
output['tags'] += 'Poster Moment' output['tags'] += 'Poster Moment'

Loading…
Cancel
Save