From 123c6f5c545bf43f408e67061440cc0b2d30b981 Mon Sep 17 00:00:00 2001 From: Galen Guyer Date: Thu, 19 Aug 2021 12:30:29 -0400 Subject: fix error on first run --- poller/__init__.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/poller/__init__.py b/poller/__init__.py index aeea1af..24b8e95 100644 --- a/poller/__init__.py +++ b/poller/__init__.py @@ -108,8 +108,11 @@ def get_data(): total_staff=-1, total_students=-1) print(current_data.serialize()) - if not data_are_same(Day.get_all()[-1], current_data): - db.session.add(current_data) + try: + if not data_are_same(Day.get_all()[-1], current_data): + db.session.add(current_data) + except IndexError: + db.session.add(current_data) dedup() return current_data @@ -125,4 +128,4 @@ def dedup(): print('dropped ' + data[i].serialize()['last_updated']) db.session.commit() -#get_data() +get_data() -- cgit v1.2.3