diff --git a/sheetsync/sheetsync/main.py b/sheetsync/sheetsync/main.py index 72bcf64..5902cf4 100644 --- a/sheetsync/sheetsync/main.py +++ b/sheetsync/sheetsync/main.py @@ -206,7 +206,7 @@ class SheetSync(object): )) query(self.conn, built_query, **row) rows_changed.labels('input', worksheet).inc() - self.middleware.mark_modified(worksheet) + self.middleware.mark_modified(row) # Update sheet with any changed outputs format_output = lambda v: '' if v is None else v # cast nulls to empty string @@ -217,11 +217,10 @@ class SheetSync(object): )) for col in changed: self.middleware.write_value( - worksheet, row, - col, format_output(getattr(event, col)), + row, col, format_output(getattr(event, col)), ) rows_changed.labels('output', worksheet).inc() - self.middleware.mark_modified(worksheet) + self.middleware.mark_modified(row) class PlaylistSync: diff --git a/sheetsync/sheetsync/sheets.py b/sheetsync/sheetsync/sheets.py index cee3c66..122430d 100644 --- a/sheetsync/sheetsync/sheets.py +++ b/sheetsync/sheetsync/sheets.py @@ -193,8 +193,8 @@ class SheetsMiddleware(): edit_link = self.edit_url.format(row['id']) if row['marked_for_edit'] == '[+] Marked' else '' if row['edit_link'] != edit_link: logging.info("Updating sheet row {} with edit link {}".format(row['id'], edit_link)) - self.write_value(worksheet, row, "edit_link", edit_link) - self.mark_modified(worksheet) + self.write_value(row, "edit_link", edit_link) + self.mark_modified(row) yield row @@ -232,17 +232,17 @@ class SheetsMiddleware(): row_dict["sheet_name"] = worksheet return row_dict - def write_value(self, worksheet, row, key, value): + def write_value(self, row, key, value): """Write key=value to the given row, as identified by worksheet + row dict.""" return self.client.write_value( self.sheet_id, - worksheet, + row["sheet_name"], row["index"], self.column_map[key], value, ) - def mark_modified(self, worksheet): - """Mark worksheet as having had a change made, bumping it to the top of + def mark_modified(self, row): + """Mark row as having had a change made, bumping its worksheet to the top of the most-recently-modified queue.""" - self.worksheets[worksheet] = monotonic() + self.worksheets[row["sheet_name"]] = monotonic() diff --git a/sheetsync/sheetsync/streamlog.py b/sheetsync/sheetsync/streamlog.py index 23d0494..9ae86e4 100644 --- a/sheetsync/sheetsync/streamlog.py +++ b/sheetsync/sheetsync/streamlog.py @@ -101,10 +101,10 @@ class StreamLogMiddleware: return output - def write_value(self, worksheet, row, key, value): + def write_value(self, row, key, value): if key in self.column_encode: value = self.column_encode[key](value) self.client.write_value(row["id"], key, value) - def mark_modified(self, worksheet): + def mark_modified(self, row): pass # not a concept we have