From 751261c2ffdc90e93869192555ae0d5e4070ff79 Mon Sep 17 00:00:00 2001 From: erdgeist Date: Mon, 3 Aug 2026 00:53:35 +0200 Subject: Display stale accounts in users#index --- app/models/user.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'app/models/user.rb') diff --git a/app/models/user.rb b/app/models/user.rb index 49c22584..adfdc564 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -10,6 +10,8 @@ class User < ApplicationRecord include Authentication::ByPassword ROLES = %w[redaktion admin alumni].freeze + STALE_AMBER_YEARS = 3 + STALE_RED_YEARS = 10 # Validations validates_presence_of :login @@ -243,6 +245,14 @@ class User < ApplicationRecord true end + def staleness_tier(now = Time.zone.now) + return nil if alumni? + return :never if last_login_at.nil? + + return :red if last_login_at <= now - STALE_RED_YEARS.years + return :amber if roles.any? && last_login_at <= now - STALE_AMBER_YEARS.years + nil + end private def roles_are_known -- cgit v1.3