sheetsync: Remove pick_worksheets() from middleware api

Instead, get_rows() makes that decision internally if needed.
pull/401/head
Mike Lang 1 year ago committed by Mike Lang
parent 17463d70fe
commit 85de9757f7

@ -104,9 +104,7 @@ class SheetSync(object):
# and comparing locally.
events = self.get_events()
worksheets = self.middleware.pick_worksheets()
for worksheet in worksheets:
for row in self.middleware.get_rows(worksheet):
for row in self.middleware.get_rows():
self.sync_row(row, events.get(row['id']))
except Exception as e:
@ -123,7 +121,7 @@ class SheetSync(object):
self.conn = self.dbmanager.get_conn()
wait(self.stop, sync_start, self.ERROR_RETRY_INTERVAL)
else:
logging.info("Successful sync of worksheets: {}".format(", ".join(worksheets)))
logging.info("Successful sync")
sheets_synced.inc()
sheet_sync_duration.observe(monotonic() - sync_start)
wait(self.stop, sync_start, self.RETRY_INTERVAL)

@ -153,8 +153,9 @@ class SheetsMiddleware():
self.sync_count += 1
return worksheets
def get_rows(self, worksheet):
def get_rows(self):
"""Fetch all rows of worksheet, parsed into a list of dicts."""
for worksheet in self.pick_worksheets():
rows = self.sheets.get_rows(self.sheet_id, worksheet)
for row_index, row in enumerate(rows):
# Skip first row (ie. the column titles).

@ -72,10 +72,6 @@ class StreamLogMiddleware:
'state': lambda v: v[0].upper() + v[1:].lower(), # Titlecase
}
def pick_worksheets(self):
# We don't have a concept of seperate worksheets, so just use a generic name
return "streamlog"
def get_rows(self):
for row in self.client.get_rows():
yield self.parse_row(row)

Loading…
Cancel
Save