diff --git a/sheetsync/sheetsync/sheets.py b/sheetsync/sheetsync/sheets.py index a0a8c6c..a81689b 100644 --- a/sheetsync/sheetsync/sheets.py +++ b/sheetsync/sheetsync/sheets.py @@ -1,7 +1,6 @@ import logging import uuid -import zoneinfo from monotonic import monotonic @@ -274,8 +273,7 @@ class SheetsEventsMiddleware(SheetsMiddleware): self.bustime_start = bustime_start self.edit_url = edit_url - # fallback to no shifts if there is a shift parsing error - self.latest_shifts = {'repeating':[], 'one_off':[], 'timezone':zoneinfo.ZoneInfo('UTC')} + self.latest_shifts = common.shifts.parse_shifts(self.shifts) # column parsers are defined here so they can reference self self.column_parsers = { @@ -300,8 +298,8 @@ class SheetsEventsMiddleware(SheetsMiddleware): # only need to update the shifts once per sync try: self.latest_shifts = common.shifts.parse_shifts(self.shifts) - except Exception as e: - logging.error('Error parsing shifts with {}. Using previous shifts definition.'.format(e)) + except Exception: + logging.exception('Error parsing shifts with. Using previous shifts definition.') return super().get_rows() @@ -339,7 +337,7 @@ class SheetsEventsMiddleware(SheetsMiddleware): # This is only needed for full events (not the archive sheet), # so only do it if we had a tags column in the first place. if 'tags' in row_dict: - shift_tag = common.shifts.calculate_shift(row_dict['event_start'], self.current_shifts) + shift_tag = common.shifts.calculate_shift(row_dict['event_start'], self.latest_shifts) row_dict['tags'] = ( ([shift_tag] if shift_tag is not None else []) [ diff --git a/thrimshim/thrimshim/main.py b/thrimshim/thrimshim/main.py index ffd8e55..7d921f2 100644 --- a/thrimshim/thrimshim/main.py +++ b/thrimshim/thrimshim/main.py @@ -245,15 +245,12 @@ def get_row(ident): if response['thumbnail_template'] is None: conn = app.db_manager.get_conn() query = """ - SELECT tags, default_template + SELECT tags[1] as tag, default_template FROM playlists - WHERE default_template IS NOT NULL + WHERE cardinality(tags) = 1 AND default_template IS NOT NULL """ results = database.query(conn, query) - default_templates = {} - for row in results: - for tag in row.tags: - default_templates[tag] = row.default_template + default_templates = {row.tag: row.default_template for row in results} # since implicit tags are put at the start, with the shift tag first # we prioritize later tags