From 2302ad9b88aa4752f4b310783984f4891d20457b Mon Sep 17 00:00:00 2001 From: yystopf Date: Thu, 23 Mar 2023 16:45:48 +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 | 18 ++++++++++++------ lib/tasks/sync_mindspore_contributors.rake | 2 +- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 1d98b17f4..8610f5f16 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -169,12 +169,18 @@ class RepositoriesController < ApplicationController end def contributors - 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] : [] + 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 end rescue @contributors = [] diff --git a/lib/tasks/sync_mindspore_contributors.rake b/lib/tasks/sync_mindspore_contributors.rake index 0c8ace17c..564ee38eb 100644 --- a/lib/tasks/sync_mindspore_contributors.rake +++ b/lib/tasks/sync_mindspore_contributors.rake @@ -65,7 +65,7 @@ namespace :sync_mindspore do total_contributions = contributions.sum{|i| i["contributions"]} contributions.each do |con| cont_balance = Float(con["contributions"]*9900/total_contributions).round(0) - token_balance << [con["id"], cont_balance] if cont_balance > 0 + token_balance << [con["id"].to_s, cont_balance] if cont_balance > 0 end params = { "request-type": "create repo",