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