From 9e3bb3ab92dab934f658a86b31f2d32c71f20913 Mon Sep 17 00:00:00 2001 From: Raul Martin Date: Fri, 21 Mar 2025 10:53:11 -0700 Subject: [PATCH] =?UTF-8?q?Revert=20"fix:=20OPTIC-1809:=20Adding=20option?= =?UTF-8?q?=20to=20only=20update=20last=5Factivity=20after=20a=20s?= =?UTF-8?q?=E2=80=A6"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 95c4ec0ae06109f8e720fd770f180d1756316467. --- label_studio/core/settings/base.py | 2 -- label_studio/users/models.py | 13 ------------- 2 files changed, 15 deletions(-) diff --git a/label_studio/core/settings/base.py b/label_studio/core/settings/base.py index 9618782c2c2c..b1be55257101 100644 --- a/label_studio/core/settings/base.py +++ b/label_studio/core/settings/base.py @@ -820,5 +820,3 @@ def collect_versions_dummy(**kwargs): } LOGOUT_REDIRECT_URL = get_env('LOGOUT_REDIRECT_URL', None) - -USER_LAST_ACTIVITY_CHECK_INTERVAL = get_env('USER_LAST_ACTIVITY_CHECK_INTERVAL', 60) diff --git a/label_studio/users/models.py b/label_studio/users/models.py index 2b8f6cc10770..97fa37b41b88 100644 --- a/label_studio/users/models.py +++ b/label_studio/users/models.py @@ -1,7 +1,6 @@ """This file and its contents are licensed under the Apache License 2.0. Please see the included NOTICE for copyright information and LICENSE for a copy of the license. """ import datetime -import logging from typing import Optional from core.utils.common import load_func @@ -19,8 +18,6 @@ from rest_framework.authtoken.models import Token from users.functions import hash_upload -logger = logging.getLogger(__name__) - YEAR_START = 1980 YEAR_CHOICES = [] for r in range(YEAR_START, (datetime.datetime.now().year + 1)): @@ -68,17 +65,7 @@ class UserLastActivityMixin(models.Model): last_activity = models.DateTimeField(_('last activity'), default=timezone.now, editable=False) def update_last_activity(self): - check_interval = settings.USER_LAST_ACTIVITY_CHECK_INTERVAL self.last_activity = timezone.now() - - if check_interval: - if (timezone.now() - self.last_activity).seconds < check_interval: - # Don't update last_activity because it's not necessary since it's close enough to the existing last_activity value - logger.info( - f'Not updating last_activity for {self.id} because last_activity of {self.last_activity} is within {check_interval} seconds of their existing last_activity value' - ) - return - self.save(update_fields=['last_activity']) class Meta: