Skip to content

Commit

Permalink
chore: filter last active nodes to 1 year
Browse files Browse the repository at this point in the history
  • Loading branch information
thepsalmist committed Nov 21, 2024
1 parent 01fdff2 commit 7b58ca3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions sensorsafrica/api/v2/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,10 @@ class NodesView(viewsets.ViewSet):
def list_nodes(self, request):
"""List all public nodes with active sensors."""
now = datetime.datetime.now()
one_hour_ago = now - datetime.timedelta(hours=1)
one_year_ago = now - datetime.timedelta(days=365)

last_active_nodes = (
LastActiveNodes.objects.filter(last_data_received_at__gte=one_hour_ago)
LastActiveNodes.objects.filter(last_data_received_at__gte=one_year_ago)
.select_related("node", "location")
.prefetch_related(
Prefetch(
Expand Down

0 comments on commit 7b58ca3

Please sign in to comment.