更改:贡献者移除获取cache数据

This commit is contained in:
yystopf 2023-03-24 23:44:24 +08:00
parent c7f21fed4f
commit 3bfc6e1c2a
2 changed files with 8 additions and 14 deletions

View File

@ -169,18 +169,12 @@ class RepositoriesController < ApplicationController
end end
def contributors def contributors
@cache_result = $redis_cache.get("ProjectSpecialCommit:#{@project.id}") if params[:filepath].present? || @project.educoder?
if @cache_result.present? @contributors = []
@total_count = Project.mindspore_contributors.size else
@contributors = kaminari_array_paginate(Project.mindspore_contributors) result = Gitea::Repository::Contributors::GetService.call(@owner, @repository.identifier, {page: params[:page], limit: params[:limit]})
else @total_count = result[:total_count]
if params[:filepath].present? || @project.educoder? @contributors = result.is_a?(Hash) ? result[:body] : []
@contributors = []
else
result = Gitea::Repository::Contributors::GetService.call(@owner, @repository.identifier, {page: params[:page], limit: params[:limit]})
@total_count = result[:total_count]
@contributors = result.is_a?(Hash) ? result[:body] : []
end
end end
rescue rescue
@contributors = [] @contributors = []

View File

@ -2,9 +2,9 @@ user = $redis_cache.hgetall("v2-owner-common:#{contributor["login"]}-#{contribut
if user.blank? if user.blank?
json.contributions contributor["contributions"] json.contributions contributor["contributions"]
# json.gid contributor["id"] # json.gid contributor["id"]
json.login contributor["login"] json.login contributor["login"].downcase
json.type nil json.type nil
json.name contributor["login"] json.name contributor["login"].downcase
json.image_url User::Avatar.get_letter_avatar_url(contributor["login"]) json.image_url User::Avatar.get_letter_avatar_url(contributor["login"])
json.contribution_perc User.new(login: contributor["login"], mail: contributor["email"]).simple_contribution_perc(project) json.contribution_perc User.new(login: contributor["login"], mail: contributor["email"]).simple_contribution_perc(project)
else else