新增:forks特殊显示逻辑

This commit is contained in:
2023-03-23 11:59:08 +08:00
parent 61c9959839
commit 7fe204056d
2 changed files with 8 additions and 2 deletions

View File

@@ -22,6 +22,12 @@ class RepositoriesController < ApplicationController
def detail
@user = current_user
@result = Repositories::DetailService.call(@owner, @repository, @user)
cache_total_forks = $redis_cache.get("ProjectSpecialForks:#{@project.id}")
if cache_total_forks.present?
@project_forked_count = @project.forked_count.to_i
else
@project_forked_count = cache_total_forks.to_i
end
@project_fork_id = @project.try(:forked_from_project_id)
if @project_fork_id.present?
@fork_project = Project.find_by(id: @project_fork_id)
@@ -322,7 +328,7 @@ class RepositoriesController < ApplicationController
def get_latest_commit
latest_commit = @project.educoder? ? nil : project_commits
@latest_commit = latest_commit.present? ? latest_commit[:body][0] : nil
cache_total_commits = $redis_cache.get("ProjectSpecialCommit:#{project.id}")
cache_total_commits = $redis_cache.get("ProjectSpecialCommit:#{@project.id}")
if cache_total_commits.present?
@commits_count = cache_total_commits.to_i
else