diff --git a/sheetsync/sheetsync/main.py b/sheetsync/sheetsync/main.py index a2f29e7..72bcf64 100644 --- a/sheetsync/sheetsync/main.py +++ b/sheetsync/sheetsync/main.py @@ -107,7 +107,7 @@ class SheetSync(object): worksheets = self.middleware.pick_worksheets() for worksheet in worksheets: 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: # for HTTPErrors, http response body includes the more detailed error @@ -152,9 +152,10 @@ class SheetSync(object): event_counts.labels(*labels).set(count) 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) and take whatever action is required to sync them, ie. writing to the database or sheet.""" + worksheet = row["sheet_name"] if event is None: # No event currently in DB, create it. diff --git a/sheetsync/sheetsync/sheets.py b/sheetsync/sheetsync/sheets.py index a262749..cee3c66 100644 --- a/sheetsync/sheetsync/sheets.py +++ b/sheetsync/sheetsync/sheets.py @@ -227,8 +227,9 @@ class SheetsMiddleware(): # As a special case, treat an end time of "--" as equal to the start time. if row_dict["event_end"] == "--": 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["sheet_name"] = worksheet return row_dict def write_value(self, worksheet, row, key, value): diff --git a/sheetsync/sheetsync/streamlog.py b/sheetsync/sheetsync/streamlog.py index 7882485..23d0494 100644 --- a/sheetsync/sheetsync/streamlog.py +++ b/sheetsync/sheetsync/streamlog.py @@ -88,10 +88,13 @@ class StreamLogMiddleware: value = self.column_decode[column](value) output[column] = value + # Section name is sheet name + output["sheet_name"] = row["section"]["name"] + # Implicit tags output['tags'] += [ output['category'], - row['section']['name'], + output["sheet_name"], ] if output["poster_moment"]: output['tags'] += 'Poster Moment'