From dacc1c57705300cc81259ea3a1b4ca44526ca387 Mon Sep 17 00:00:00 2001 From: sadnub Date: Thu, 14 Apr 2022 17:58:51 -0400 Subject: [PATCH] fix cache not hitting if it returns an empty list --- api/tacticalrmm/agents/models.py | 4 ++-- api/tacticalrmm/automation/models.py | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/api/tacticalrmm/agents/models.py b/api/tacticalrmm/agents/models.py index a9f83205..febd31d3 100644 --- a/api/tacticalrmm/agents/models.py +++ b/api/tacticalrmm/agents/models.py @@ -683,7 +683,7 @@ class Agent(BaseAuditModel): cache_key = f"site_{self.monitoring_type}_{self.site_id}_checks" cached_checks = cache.get(cache_key) - if cached_checks and isinstance(cached_checks, list): + if isinstance(cached_checks, list): return cached_checks else: # clear agent checks that have overridden_by_policy set @@ -708,7 +708,7 @@ class Agent(BaseAuditModel): cache_key = f"site_{self.monitoring_type}_{self.site_id}_tasks" cached_tasks = cache.get(cache_key) - if cached_tasks and isinstance(cached_tasks, list): + if isinstance(cached_tasks, list): return cached_tasks else: # get agent tasks based on policies diff --git a/api/tacticalrmm/automation/models.py b/api/tacticalrmm/automation/models.py index 29cca9bd..fd769936 100644 --- a/api/tacticalrmm/automation/models.py +++ b/api/tacticalrmm/automation/models.py @@ -251,6 +251,9 @@ class Policy(BaseAuditModel): for check in policy.policychecks.all(): policy_checks.append(check) + if not enforced_checks and not policy_checks: + return [] + # Sorted Checks already added added_diskspace_checks: List[str] = list() added_ping_checks: List[str] = list()