mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-07-13 21:44:32 +08:00
add: callback cache
This commit is contained in:
+23
-5
@@ -20,12 +20,30 @@ class ForkUser < ApplicationRecord
|
||||
belongs_to :user
|
||||
belongs_to :fork_project, class_name: 'Project', foreign_key: :fork_project_id
|
||||
|
||||
after_save :reset_cache_data
|
||||
after_destroy :reset_cache_data
|
||||
after_create :incre_project_common, :incre_user_statistic, :incre_platform_statistic
|
||||
after_destroy :decre_project_common, :decre_user_statistic, :decre_platform_statistic
|
||||
|
||||
def reset_cache_data
|
||||
CacheAsyncResetJob.perform_later("platform_statistic_service")
|
||||
CacheAsyncResetJob.perform_later("user_statistic_service", self.project&.user_id)
|
||||
def incre_project_common
|
||||
CacheAsyncSetJob.perform_later("project_common_service", {forks: 1}, self.project_id)
|
||||
end
|
||||
|
||||
def decre_project_common
|
||||
CacheAsyncSetJob.perform_later("project_common_service", {forks: -1}, self.project_id)
|
||||
end
|
||||
|
||||
def incre_user_statistic
|
||||
CacheAsyncSetJob.perform_later("user_statistic_service", {fork_count: 1}, self.project&.user_id)
|
||||
end
|
||||
|
||||
def decre_user_statistic
|
||||
CacheAsyncSetJob.perform_later("user_statistic_service", {fork_count: -1}, self.project&.user_id)
|
||||
end
|
||||
|
||||
def incre_platform_statistic
|
||||
CacheAsyncSetJob.perform_later("platform_statistic_service", {fork_count: 1})
|
||||
end
|
||||
|
||||
def decre_platform_statistic
|
||||
CacheAsyncSetJob.perform_later("platform_statistic_service", {fork_count: -1})
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user