From 000be2de6da6fec93103a20362f6350c851551cc Mon Sep 17 00:00:00 2001 From: albert Date: Thu, 7 Jun 2012 17:31:55 -0400 Subject: [PATCH] update users last_logged_in_at more frequently, disable tag subscription processing for users who have been inactive for more than one year --- app/logical/session_loader.rb | 9 ++++++++- app/models/tag_subscription.rb | 6 +++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app/logical/session_loader.rb b/app/logical/session_loader.rb index f46cafac1..4513ed36e 100644 --- a/app/logical/session_loader.rb +++ b/app/logical/session_loader.rb @@ -19,7 +19,8 @@ class SessionLoader else CurrentUser.user = AnonymousUser.new end - + + update_last_logged_in_at set_time_zone end @@ -43,6 +44,12 @@ private cookies[:cookie_password_hash] && User.authenticate_cookie_hash(cookies[:user_name], cookies[:cookie_password_hash]) end + def update_last_logged_in_at + return if CurrentUser.is_anonymous? + return if CurrentUser.last_logged_in_at && CurrentUser.last_logged_in_at > 1.week.ago + CurrentUser.user.update_attribute(:last_logged_in_at, Time.now) + end + def set_time_zone Time.zone = CurrentUser.user.time_zone end diff --git a/app/models/tag_subscription.rb b/app/models/tag_subscription.rb index 4c48505fe..cff516b3f 100644 --- a/app/models/tag_subscription.rb +++ b/app/models/tag_subscription.rb @@ -34,6 +34,10 @@ class TagSubscription < ActiveRecord::Base self.post_ids = post_ids.sort.reverse.slice(0, Danbooru.config.tag_subscription_post_limit).join(",") end + def is_active? + creator.last_logged_in_at && creator.last_logged_in_at > 1.year.ago + end + def editable_by?(user) user.is_moderator? || creator_id == user.id end @@ -86,7 +90,7 @@ class TagSubscription < ActiveRecord::Base def self.process_all find_each do |tag_subscription| - if $job_task_daemon_active != false && tag_subscription.creator.is_privileged? + if $job_task_daemon_active != false && tag_subscription.creator.is_privileged? && tag_subscription.is_active? begin tag_subscription.process tag_subscription.save