diff options
author | Galen Guyer <galen@galenguyer.com> | 2021-08-19 12:30:29 -0400 |
---|---|---|
committer | Galen Guyer <galen@galenguyer.com> | 2021-08-19 12:30:29 -0400 |
commit | 123c6f5c545bf43f408e67061440cc0b2d30b981 (patch) | |
tree | 593de5a9b7b9c223147ee530593732013f872145 /poller | |
parent | 9dda1c9ed4e7e039ac894179b2d06c5e6c68180f (diff) |
fix error on first run
Diffstat (limited to 'poller')
-rw-r--r-- | poller/__init__.py | 9 |
1 files 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() |