Add records that indicate a user's avatar has been checked

This commit is contained in:
Robin Ward 2013-09-12 14:58:20 -04:00
parent 4599e5d732
commit 3fcd331d43
3 changed files with 17 additions and 2 deletions

View File

@ -5,7 +5,6 @@ class UserHistory < ActiveRecord::Base
belongs_to :acting_user, class_name: 'User'
belongs_to :target_user, class_name: 'User'
validates_presence_of :acting_user_id
validates_presence_of :action
scope :only_staff_actions, ->{ where("action IN (?)", UserHistory.staff_action_ids) }
@ -15,7 +14,9 @@ class UserHistory < ActiveRecord::Base
:change_trust_level,
:change_site_setting,
:change_site_customization,
:delete_site_customization)
:delete_site_customization,
:checked_for_custom_avatar,
:notified_about_avatar)
end
# Staff actions is a subset of all actions, used to audit actions taken by staff users.

View File

@ -0,0 +1,10 @@
class ActingUserNull < ActiveRecord::Migration
def up
change_column :user_histories, :acting_user_id, :integer, :null => true
end
def down
execute "DELETE FROM user_histories WHERE acting_user_id IS NULL"
change_column :user_histories, :acting_user_id, :integer, :null => false
end
end

View File

@ -17,6 +17,10 @@ module Jobs
if user_stats.present?
user_stats.each do |us|
us.update_column(:has_custom_avatar, true) if AvatarDetector.new(us.user).has_custom_avatar?
UserHistory.create!(
action: UserHistory.actions[:checked_for_custom_avatar],
target_user_id: us.user_id
)
end
end
end