More bug fixes

pull/449/head
Christopher Usher 3 weeks ago
parent 7ed0bbedc4
commit b4882a9fc4

@ -1,7 +1,6 @@
import logging import logging
import uuid import uuid
import zoneinfo
from monotonic import monotonic from monotonic import monotonic
@ -274,8 +273,7 @@ class SheetsEventsMiddleware(SheetsMiddleware):
self.bustime_start = bustime_start self.bustime_start = bustime_start
self.edit_url = edit_url self.edit_url = edit_url
# fallback to no shifts if there is a shift parsing error self.latest_shifts = common.shifts.parse_shifts(self.shifts)
self.latest_shifts = {'repeating':[], 'one_off':[], 'timezone':zoneinfo.ZoneInfo('UTC')}
# column parsers are defined here so they can reference self # column parsers are defined here so they can reference self
self.column_parsers = { self.column_parsers = {
@ -300,8 +298,8 @@ class SheetsEventsMiddleware(SheetsMiddleware):
# only need to update the shifts once per sync # only need to update the shifts once per sync
try: try:
self.latest_shifts = common.shifts.parse_shifts(self.shifts) self.latest_shifts = common.shifts.parse_shifts(self.shifts)
except Exception as e: except Exception:
logging.error('Error parsing shifts with {}. Using previous shifts definition.'.format(e)) logging.exception('Error parsing shifts with. Using previous shifts definition.')
return super().get_rows() return super().get_rows()
@ -339,7 +337,7 @@ class SheetsEventsMiddleware(SheetsMiddleware):
# This is only needed for full events (not the archive sheet), # 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. # so only do it if we had a tags column in the first place.
if 'tags' in row_dict: 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'] = ( row_dict['tags'] = (
([shift_tag] if shift_tag is not None else []) ([shift_tag] if shift_tag is not None else [])
[ [

@ -245,15 +245,12 @@ def get_row(ident):
if response['thumbnail_template'] is None: if response['thumbnail_template'] is None:
conn = app.db_manager.get_conn() conn = app.db_manager.get_conn()
query = """ query = """
SELECT tags, default_template SELECT tags[1] as tag, default_template
FROM playlists FROM playlists
WHERE default_template IS NOT NULL WHERE cardinality(tags) = 1 AND default_template IS NOT NULL
""" """
results = database.query(conn, query) results = database.query(conn, query)
default_templates = {} default_templates = {row.tag: row.default_template for row in results}
for row in results:
for tag in row.tags:
default_templates[tag] = row.default_template
# since implicit tags are put at the start, with the shift tag first # since implicit tags are put at the start, with the shift tag first
# we prioritize later tags # we prioritize later tags

Loading…
Cancel
Save