Skip to content

Commit

Permalink
List event times for deleted schedule items
Browse files Browse the repository at this point in the history
Also runs the task every hour, instead of every 12 hours.
  • Loading branch information
kitsuta committed Jan 17, 2025
1 parent c8b093a commit 3e59d07
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions uber/tasks/panels.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import json

from collections import defaultdict
from datetime import timedelta
from datetime import timedelta, datetime
from dateutil import parser as dateparser
from sqlalchemy import or_

Expand Down Expand Up @@ -31,16 +31,27 @@ def _get_deleted_models(session, deleted_since=None):

for tracking_entry in deleted_synced:
snapshot = json.loads(tracking_entry.snapshot)
guidebook_data = snapshot['last_synced']['data']['guidebook']

model = snapshot['_model']
if model == 'GuestGroup':
model += '_band' if snapshot['group_type'] == c.BAND else '_guest'
elif model == 'Group':
model += '_dealer'

model_name = 'Schedule Item' if model == 'Event' else model_names[model]

deleted_models[model_name].append(snapshot['last_synced']['data']['guidebook']['name'])
if model == 'Event':
model_name = 'Schedule Item'
start_day = datetime.strptime(guidebook_data['start_date'], '%d/%M/%Y').strftime('%A (%-m/%-d/%Y)')
end_day = datetime.strptime(guidebook_data['end_date'], '%d/%M/%Y').strftime('%A (%-m/%-d/%Y)')
if start_day != end_day:
item_name = f"{guidebook_data['name']} on {start_day} {guidebook_data['start_time']} to {end_day} {guidebook_data['end_time']}"
else:
item_name = f"{guidebook_data['name']} on {start_day} {guidebook_data['start_time']} to {guidebook_data['end_time']}"
else:
model_names[model]
item_name = guidebook_data['name']

deleted_models[model_name].append(item_name)
return deleted_models


Expand All @@ -62,7 +73,7 @@ def sync_guidebook_models(selected_model, sync_time, id_list):
session.commit()


@celery.schedule(timedelta(hours=12))
@celery.schedule(timedelta(hours=1))
def check_deleted_guidebook_models():
if not c.PRE_CON or not c.GUIDEBOOK_UPDATES_EMAIL:
return
Expand Down

0 comments on commit 3e59d07

Please sign in to comment.