From 64d9d21457f2a9b25c0a8a59e08df32af03bad54 Mon Sep 17 00:00:00 2001 From: yystopf Date: Thu, 23 Mar 2023 17:01:19 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=EF=BC=9A=E5=8C=BA=E5=9D=97?= =?UTF-8?q?=E7=A1=AE=E6=9D=83=E8=B4=A1=E7=8C=AE=E8=80=85=E5=B1=95=E7=A4=BA?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/repositories_controller.rb | 4 ++-- app/views/repositories/_contributor.json.jbuilder | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 8610f5f16..d7fdb51ac 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -169,8 +169,8 @@ class RepositoriesController < ApplicationController end def contributors - cache_result = $redis_cache.get("ProjectSpecialCommit:#{@project.id}") - if cache_result.present? + @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 diff --git a/app/views/repositories/_contributor.json.jbuilder b/app/views/repositories/_contributor.json.jbuilder index c8b2db373..dca0a93bf 100644 --- a/app/views/repositories/_contributor.json.jbuilder +++ b/app/views/repositories/_contributor.json.jbuilder @@ -6,6 +6,12 @@ if user.blank? json.type nil json.name contributor["login"] json.image_url User::Avatar.get_letter_avatar_url(contributor["login"]) + if @cache_result.present? + db_user = User.find_by_id(contributor["id"]) + if db_user.present? + json.contribution_perc db_user.contribution_perc(project) + end + end else json.contributions contributor["contributions"] # json.gid contributor["id"]