From 3bfc6e1c2a7f713c99370bf7764aa06ab88cc2c2 Mon Sep 17 00:00:00 2001 From: yystopf Date: Fri, 24 Mar 2023 23:44:24 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=94=B9=EF=BC=9A=E8=B4=A1=E7=8C=AE?= =?UTF-8?q?=E8=80=85=E7=A7=BB=E9=99=A4=E8=8E=B7=E5=8F=96cache=E6=95=B0?= =?UTF-8?q?=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/repositories_controller.rb | 18 ++++++------------ .../repositories/_contributor.json.jbuilder | 4 ++-- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index d7fdb51ac..1d98b17f4 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -169,18 +169,12 @@ class RepositoriesController < ApplicationController end def contributors - @cache_result = $redis_cache.get("ProjectSpecialCommit:#{@project.id}") - if @cache_result.present? - @total_count = Project.mindspore_contributors.size - @contributors = kaminari_array_paginate(Project.mindspore_contributors) - else - if params[:filepath].present? || @project.educoder? - @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 + if params[:filepath].present? || @project.educoder? + @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 rescue @contributors = [] diff --git a/app/views/repositories/_contributor.json.jbuilder b/app/views/repositories/_contributor.json.jbuilder index d1bc16024..e93bdf370 100644 --- a/app/views/repositories/_contributor.json.jbuilder +++ b/app/views/repositories/_contributor.json.jbuilder @@ -2,9 +2,9 @@ user = $redis_cache.hgetall("v2-owner-common:#{contributor["login"]}-#{contribut if user.blank? json.contributions contributor["contributions"] # json.gid contributor["id"] - json.login contributor["login"] + json.login contributor["login"].downcase json.type nil - json.name contributor["login"] + json.name contributor["login"].downcase 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) else