Skip to content
Snippets Groups Projects

Get rid of user activites table and replace it with redis

Merged James Lopez requested to merge fix/user-activities-performance into master
All threads resolved!
Files
2
+ 6
2
@@ -96,7 +96,6 @@ class User < ActiveRecord::Base
@@ -96,7 +96,6 @@ class User < ActiveRecord::Base
has_many :notification_settings, dependent: :destroy
has_many :notification_settings, dependent: :destroy
has_many :award_emoji, dependent: :destroy
has_many :award_emoji, dependent: :destroy
has_many :path_locks, dependent: :destroy
has_many :path_locks, dependent: :destroy
has_one :user_activity, dependent: :destroy
# Protected Branch Access
# Protected Branch Access
has_many :protected_branch_merge_access_levels, dependent: :destroy, class_name: ProtectedBranch::MergeAccessLevel
has_many :protected_branch_merge_access_levels, dependent: :destroy, class_name: ProtectedBranch::MergeAccessLevel
@@ -153,7 +152,6 @@ class User < ActiveRecord::Base
@@ -153,7 +152,6 @@ class User < ActiveRecord::Base
alias_attribute :private_token, :authentication_token
alias_attribute :private_token, :authentication_token
delegate :path, to: :namespace, allow_nil: true, prefix: true
delegate :path, to: :namespace, allow_nil: true, prefix: true
delegate :last_activity_at, to: :user_activity, allow_nil: true
state_machine :state, initial: :active do
state_machine :state, initial: :active do
event :block do
event :block do
@@ -964,6 +962,12 @@ class User < ActiveRecord::Base
@@ -964,6 +962,12 @@ class User < ActiveRecord::Base
end
end
end
end
 
def record_activity
 
Gitlab::Redis.with do |redis|
 
redis.zadd('user/activities', Time.now.to_i, self.username)
 
end
 
end
 
private
private
# Returns a union query of projects that the user is authorized to access
# Returns a union query of projects that the user is authorized to access
Loading