Merge remote-tracking branch 'origin/standalone_develop' into standalone_develop
This commit is contained in:
commit
9f123995ee
|
@ -31,6 +31,26 @@ module Watchable
|
|||
following.size
|
||||
end
|
||||
|
||||
def simple_contribution_perc(project, perc=nil)
|
||||
@project = project
|
||||
@user = self
|
||||
|
||||
def cal_perc(count_user, count_all)
|
||||
(count_user * 1.0 / (count_all + 0.000000001)).round(5)
|
||||
end
|
||||
|
||||
if (@project['use_blockchain'] == true or @project['use_blockchain'] == 1) && @user.id.present?
|
||||
balance_user = Blockchain::BalanceQueryOneProject.call({"user_id": @user.id, "project_id": @project.id})
|
||||
balance_all = Blockchain::RepoBasicInfo.call({"project_id": @project.id})["cur_supply"]
|
||||
score = cal_perc(balance_user, balance_all)
|
||||
score = (score * 100).round(1).to_s + "%"
|
||||
else
|
||||
score = perc
|
||||
end
|
||||
|
||||
score
|
||||
end
|
||||
|
||||
def contribution_perc(project)
|
||||
@project = project
|
||||
@user = self
|
||||
|
|
|
@ -9,6 +9,7 @@ json.user_admin_or_developer @user_admin_or_developer
|
|||
json.project_name @project.name
|
||||
json.project_author @project.owner.try(:login)
|
||||
json.project_author_name @project.owner.try(:show_real_name)
|
||||
json.has_created_pull_requests @project.pull_requests.size > 0
|
||||
|
||||
json.issues do
|
||||
json.array! @issues.to_a do |issue|
|
||||
|
|
|
@ -1,18 +1,21 @@
|
|||
user = $redis_cache.hgetall("v2-owner-common:#{contributor["login"]}-#{contributor["email"]}")
|
||||
user = $redis_cache.hgetall("v2-owner-common:#{contributor["name"]}-#{contributor["email"]}")
|
||||
if user.blank?
|
||||
json.contributions contributor["contributions"]
|
||||
json.contributions contributor["commits"]
|
||||
# json.gid contributor["id"]
|
||||
json.login contributor["login"]
|
||||
json.login nil
|
||||
json.type nil
|
||||
json.name contributor["login"]
|
||||
json.image_url User::Avatar.get_letter_avatar_url(contributor["login"])
|
||||
json.name contributor["name"].downcase
|
||||
json.email contributor["email"]
|
||||
json.image_url User::Avatar.get_letter_avatar_url(contributor["name"])
|
||||
json.contribution_perc User.new(login: contributor["name"], mail: contributor["email"]).simple_contribution_perc(project, contributor["contribution_perc"])
|
||||
else
|
||||
json.contributions contributor["contributions"]
|
||||
json.contributions contributor["commits"]
|
||||
json.id user["id"]
|
||||
# json.gid contributor["id"]
|
||||
json.login user["login"]
|
||||
json.login user["login"].downcase
|
||||
json.type user["type"]
|
||||
json.name user["name"]
|
||||
json.name user["name"].downcase
|
||||
json.image_url user["avatar_url"]
|
||||
db_user = User.find_by_id(user["id"])
|
||||
json.contribution_perc db_user.contribution_perc(project) if db_user.present?
|
||||
json.contribution_perc db_user.simple_contribution_perc(project, contributor["contribution_perc"]) if db_user.present?
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue