更改:贡献占比展示在贡献者页面
This commit is contained in:
parent
29217ff345
commit
4b5df918fc
|
@ -45,11 +45,13 @@ module Watchable
|
|||
score = cal_perc(balance_user, balance_all)
|
||||
else
|
||||
contributors = []
|
||||
result = Gitea::Repository::Contributors::GetService.call(@owner, @repository.identifier,{q_name: self.login, q_email: self.mail})
|
||||
result = Gitea::Repository::Contributors::GetService.call(@user, @project.identifier,{q_name: @user.login, q_email: @user.mail})
|
||||
user_contribution = result[:body][0]
|
||||
commits_all = result[:total_contributions]
|
||||
score = cal_perc(user_contribution["contributions"], commits_all)
|
||||
end
|
||||
|
||||
(score * 100).round(1).to_s + "%"
|
||||
end
|
||||
|
||||
def contribution_perc(project)
|
||||
|
|
|
@ -6,12 +6,7 @@ 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
|
||||
json.contribution_perc User.new(login: contributor["login"], mail: contributor["email"]).simple_contribution_perc(project)
|
||||
else
|
||||
json.contributions contributor["contributions"]
|
||||
# json.gid contributor["id"]
|
||||
|
@ -21,6 +16,6 @@ else
|
|||
json.image_url user["avatar_url"]
|
||||
db_user = User.find_by_id(user["id"])
|
||||
if db_user.present?
|
||||
json.contribution_perc db_user.contribution_perc(project)
|
||||
json.contribution_perc db_user.simple_contribution_perc(project)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue