Skip to content

fix: OPTIC-1809: Adding option to only update last_activity after a significant difference #7216

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Mar 19, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions label_studio/core/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -822,3 +822,5 @@ 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)
6 changes: 6 additions & 0 deletions label_studio/users/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ class UserLastActivityMixin(models.Model):
last_activity = models.DateTimeField(_('last activity'), default=timezone.now, editable=False)

def update_last_activity(self):
check_interval = getattr(settings, 'USER_LAST_ACTIVITY_CHECK_INTERVAL', None)
if check_interval:
if timezone.now() - self.last_activity < check_interval:
# Don't update last_activity because it's not necessary since it's close enough to the existing last_activity value
return

self.last_activity = timezone.now()
self.save(update_fields=['last_activity'])

Expand Down
Loading