fix cache not hitting if it returns an empty list

This commit is contained in:
sadnub 2022-04-14 17:58:51 -04:00
parent 25e922bc4c
commit dacc1c5770
2 changed files with 5 additions and 2 deletions

View File

@ -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

View File

@ -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()