From 6afd275814e5cc34646a5c0706893ed8d36e41d4 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Wed, 17 May 2023 21:18:26 +0800 Subject: [PATCH] =?UTF-8?q?fixed=20=E6=8F=90=E4=BA=A4=E8=80=85=E5=8C=B9?= =?UTF-8?q?=E9=85=8D=E7=94=A8=E6=88=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/v1/projects/code_stats_controller.rb | 2 +- .../repositories/_commit_author.json.jbuilder | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/app/controllers/api/v1/projects/code_stats_controller.rb b/app/controllers/api/v1/projects/code_stats_controller.rb index 0f2b2dd3..efe76553 100644 --- a/app/controllers/api/v1/projects/code_stats_controller.rb +++ b/app/controllers/api/v1/projects/code_stats_controller.rb @@ -2,7 +2,7 @@ class Api::V1::Projects::CodeStatsController < Api::V1::BaseController before_action :require_public_and_member_above, only: [:index] def index - @result_object = Api::V1::Projects::CodeStats::ListService.call(@project, {ref: params[:ref]}, current_user&.gitea_token) + @result_object = Api::V1::Projects::CodeStats::ListService.call(@project, {ref: params[:ref]}, @project.owner&.gitea_token) # puts @result_object end end \ No newline at end of file diff --git a/app/views/repositories/_commit_author.json.jbuilder b/app/views/repositories/_commit_author.json.jbuilder index 83935709..68c61a70 100644 --- a/app/views/repositories/_commit_author.json.jbuilder +++ b/app/views/repositories/_commit_author.json.jbuilder @@ -1,16 +1,17 @@ if user.present? - if user.is_a?(Hash) + if user.is_a?(Hash) && user["id"].present? json.id user["id"] json.login user["login"] json.name user["name"] json.type user["type"] json.image_url user["avatar_url"] - else - json.id user.id - json.login user.login - json.name user.real_name - json.type user&.type - json.image_url url_to_avatar(user) + elsif user.is_a?(Hash) && user["email"].present? + db_user = User.find_by(mail: user["email"]) + json.id db_user&.id + json.login db_user&.login || user["login"] + json.name db_user&.real_name || user["name"] + json.type db_user&.type + json.image_url db_user.present? ? url_to_avatar(db_user) : "" end else json.id nil