sheetsync: Remove worksheet from middleware apis

since it's now baked into the row dict
pull/401/head
Mike Lang 1 year ago committed by Mike Lang
parent eec58f2651
commit 17463d70fe

@ -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:

@ -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()

@ -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

Loading…
Cancel
Save