FIX & PERF: vanilla import

PERF: disabled refresh_avatar callback when importing users
PERF: avoid using UsernameSuggester when not needed
FIX: categories wasn't working
FIX: posts from deleted users are now from the system user
This commit is contained in:
Régis Hanol
2014-08-13 22:17:16 +02:00
parent 6201b82a67
commit 4c4ce05964
3 changed files with 46 additions and 28 deletions

View File

@ -67,19 +67,20 @@ class User < ActiveRecord::Base
validate :password_validator
validates :ip_address, allowed_ip_address: {on: :create, message: :signup_not_allowed}
before_save :update_username_lower
before_save :ensure_password_is_hashed
after_initialize :add_trust_level
after_initialize :set_default_email_digest
after_initialize :set_default_external_links_in_new_tab
after_save :update_tracked_topics
after_save :clear_global_notice_if_needed
after_create :create_email_token
after_create :create_user_stat
after_create :create_user_profile
after_create :ensure_in_trust_level_group
before_save :update_username_lower
before_save :ensure_password_is_hashed
after_save :update_tracked_topics
after_save :clear_global_notice_if_needed
after_save :refresh_avatar
after_save :badge_grant
@ -95,6 +96,9 @@ class User < ActiveRecord::Base
# This is just used to pass some information into the serializer
attr_accessor :notification_channel_position
# set to true to optimize creation and save for imports
attr_accessor :import_mode
scope :blocked, -> { where(blocked: true) } # no index
scope :not_blocked, -> { where(blocked: false) } # no index
scope :suspended, -> { where('suspended_till IS NOT NULL AND suspended_till > ?', Time.zone.now) } # no index
@ -594,6 +598,8 @@ class User < ActiveRecord::Base
end
def refresh_avatar
return if @import_mode
avatar = user_avatar || create_user_avatar
gravatar_downloaded = false