Browse Source

fix: privacy project not use cache

tags/v4.0.0
yystopf 4 years ago
parent
commit
d0791ee653
3 changed files with 12 additions and 0 deletions
  1. +8
    -0
      app/models/project.rb
  2. +3
    -0
      app/services/cache/v2/project_common_service.rb
  3. +1
    -0
      app/views/project_rank/_detail.json.jbuilder

+ 8
- 0
app/models/project.rb View File

@@ -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]


+ 3
- 0
app/services/cache/v2/project_common_service.rb View File

@@ -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


+ 1
- 0
app/views/project_rank/_detail.json.jbuilder View File

@@ -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…
Cancel
Save