forked from Gitlink/forgeplus
fix: privacy project not use cache
This commit is contained in:
parent
e1b0abbf31
commit
d0791ee653
|
@ -190,6 +190,14 @@ class Project < ApplicationRecord
|
|||
CacheAsyncSetJob.perform_later("platform_statistic_service", {project_count: -1, project_language_count_key: self.project_language&.name, project_language_count: -1})
|
||||
end
|
||||
|
||||
def is_full_public
|
||||
owner = self.owner
|
||||
if owner.is_a?(Organization)
|
||||
return self.is_public && owner&.visibility == "common"
|
||||
else
|
||||
return self.is_public
|
||||
end
|
||||
end
|
||||
|
||||
def reset_unmember_followed
|
||||
if changes[:is_public].present? && changes[:is_public] == [true, false]
|
||||
|
|
|
@ -86,6 +86,8 @@ class Cache::V2::ProjectCommonService < ApplicationService
|
|||
reset_project_common
|
||||
return
|
||||
end
|
||||
load_project
|
||||
return unless @project.is_full_public
|
||||
if @owner_id.present?
|
||||
if $redis_cache.hget(project_common_key, owner_id_key).nil?
|
||||
reset_project_owner_id
|
||||
|
@ -224,6 +226,7 @@ class Cache::V2::ProjectCommonService < ApplicationService
|
|||
|
||||
def reset_project_common
|
||||
load_project
|
||||
return unless @project.is_full_public
|
||||
$redis_cache.del(project_common_key)
|
||||
reset_project_owner_id
|
||||
reset_project_name
|
||||
|
|
|
@ -7,6 +7,7 @@ json.identifier project_common["identifier"]
|
|||
json.description project_common["description"]
|
||||
json.owner do
|
||||
json.id project_common["owner_id"]
|
||||
json type owner_common["type"]
|
||||
json.name owner_common["name"]
|
||||
json.login owner_common["login"]
|
||||
json.avatar_url owner_common["avatar_url"]
|
||||
|
|
Loading…
Reference in New Issue