From 8be690c417a2fb8774f147a300f26fa5b8d6203c Mon Sep 17 00:00:00 2001 From: Oliver Kamer <3026203+olikami@users.noreply.github.com> Date: Tue, 19 Jan 2021 11:32:36 +0100 Subject: [PATCH] Use heartbeat frequency for currently active If the heartbeat frequency is more than 10 seconds, shynet will display as not active, even though it still is. Using 2x the heartbeat frequency should give better results. --- shynet/analytics/models.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/shynet/analytics/models.py b/shynet/analytics/models.py index 3b37b93..3ddaf0c 100644 --- a/shynet/analytics/models.py +++ b/shynet/analytics/models.py @@ -1,6 +1,7 @@ import json import uuid +from django.conf import settings from django.db import models from django.shortcuts import reverse from django.utils import timezone @@ -57,7 +58,7 @@ class Session(models.Model): @property def is_currently_active(self): - return timezone.now() - self.last_seen < timezone.timedelta(seconds=10) + return timezone.now() - self.last_seen < timezone.timedelta(milliseconds=settings.SCRIPT_HEARTBEAT_FREQUENCY * 2) @property def duration(self):