Skip to content

Commit

Permalink
DBC22-1352: event and camera feeds now check timestamp before querying (
Browse files Browse the repository at this point in the history
  • Loading branch information
ray-oxd authored Dec 1, 2023
1 parent 211ab9e commit 1738d6c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
8 changes: 5 additions & 3 deletions src/backend/apps/event/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ def populate_event_from_data(event_data):
except ObjectDoesNotExist:
event = Event(id=event_id)

event_serializer = EventSerializer(event, data=event_data)
event_serializer.is_valid(raise_exception=True)
event_serializer.save()
# Only update data if official last updated timestamp is different
if event.last_updated != event_data['last_updated']:
event_serializer = EventSerializer(event, data=event_data)
event_serializer.is_valid(raise_exception=True)
event_serializer.save()


def populate_all_event_data():
Expand Down
9 changes: 6 additions & 3 deletions src/backend/apps/webcam/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,12 @@ def populate_all_webcam_data():

def update_single_webcam_data(webcam):
webcam_data = FeedClient().get_webcam(webcam)
webcam_serializer = WebcamSerializer(webcam, data=webcam_data)
webcam_serializer.is_valid(raise_exception=True)
webcam_serializer.save()

# Only update data if official last updated timestamp is different
if webcam.last_update_modified != webcam_data['last_update_modified']:
webcam_serializer = WebcamSerializer(webcam, data=webcam_data)
webcam_serializer.is_valid(raise_exception=True)
webcam_serializer.save()


def update_all_webcam_data():
Expand Down

0 comments on commit 1738d6c

Please sign in to comment.