Skip to content

Commit

Permalink
added comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael-R-Dickinson committed Sep 29, 2024
1 parent 55b392a commit 855aec9
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/websocket/sockets.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,13 @@ def process_drone_update(data: dict) -> None:
from drone.models import DroneTelemetry
from drone.serializers import DroneTelemetrySerializer

# Validate telemetry data
telemetry = DroneTelemetrySerializer(data=data)
telemetry.is_valid(raise_exception=True)

telemetry.save()

# Drop records older than 5 minutes
cutoff_time = (datetime.now() - timedelta(minutes=5)).timestamp()
old_records = DroneTelemetry.objects.filter(timestamp__lt=int(cutoff_time))
old_records.delete()

0 comments on commit 855aec9

Please sign in to comment.