Commit 0ab234ad892a7d96a81eb5cb21d694734a7467e4

Authored by Alexis Koralewski
1 parent 3dd318d0
Exists in dev

Filter agent state api (not display state if agent is not updated since two days)

Showing 2 changed files with 10 additions and 2 deletions   Show diff stats
CHANGELOG
1 1 12-10-2022 (AKo): v0.6.1.0
  2 + - Filter agent state api (not display state if agent is not updated since two days)
2 3 - Update variable name in agent_detail & use method to check cmd status
3 4 - Adding do_restart_agent soft/hard mode
4 5 - Fixing display of get_specific_cmd error and sort
... ...
src/core/pyros_django/api/views.py
... ... @@ -11,7 +11,7 @@ from common.models import PyrosUser, SP_Period, ScientificProgram, Sequence, Alb
11 11 from routine_manager.functions import check_sequence_file_validity
12 12 from rest_framework.request import Request
13 13 from django.db.models import Q
14   -from datetime import datetime
  14 +from datetime import datetime, timezone, timedelta
15 15 from src.pyros_logger import log
16 16  
17 17 # Create your views here.
... ... @@ -249,4 +249,11 @@ class AgentSurveyViewSet(viewsets.ModelViewSet):
249 249 serializer_class = AgentSurveySerializer
250 250 permission_classes = [IsAuthenticated]
251 251 http_method_names = ["get"]
252   - lookup_field = "name"
253 252 \ No newline at end of file
  253 + lookup_field = "name"
  254 + def get_queryset(self):
  255 + agents = AgentSurvey.objects.all()
  256 + datetime_now = datetime.utcnow()
  257 + date_minus_two_days = datetime_now - timedelta(days=2)
  258 + date_minus_two_days = date_minus_two_days.replace(tzinfo=timezone.utc)
  259 + agents = agents.exclude(updated__lt=date_minus_two_days)
  260 + return agents
254 261 \ No newline at end of file
... ...