新增:转账记录使用json builder以及贡献者新增贡献占比
This commit is contained in:
parent
90773483b8
commit
47a8f17073
|
@ -423,7 +423,7 @@ class UsersController < ApplicationController
|
||||||
@projects = []
|
@projects = []
|
||||||
end
|
end
|
||||||
|
|
||||||
render json: { status: results[:status], projects: @projects, total_count: @total_count }
|
# render json: { status: results[:status], projects: @projects, total_count: @total_count }
|
||||||
end
|
end
|
||||||
|
|
||||||
# query one balance
|
# query one balance
|
||||||
|
|
|
@ -31,11 +31,9 @@ module Watchable
|
||||||
following.size
|
following.size
|
||||||
end
|
end
|
||||||
|
|
||||||
def contribution_perc
|
def contribution_perc(project)
|
||||||
project_identifier = params[:project_identifier]
|
@project = project
|
||||||
user_login = params[:id]
|
@user = self
|
||||||
@project = Project.find_by_identifier(project_identifier)
|
|
||||||
@user = User.find_by_login(user_login)
|
|
||||||
|
|
||||||
def cal_perc(count_user, count_all)
|
def cal_perc(count_user, count_all)
|
||||||
(count_user * 1.0 / (count_all + 0.000000001)).round(5)
|
(count_user * 1.0 / (count_all + 0.000000001)).round(5)
|
||||||
|
|
|
@ -20,7 +20,7 @@ class Blockchain::BalanceQuery < ApplicationQuery
|
||||||
if owner.nil? || project.nil?
|
if owner.nil? || project.nil?
|
||||||
else
|
else
|
||||||
balance = t['balance']
|
balance = t['balance']
|
||||||
result_list << [owner, project, balance]
|
result_list << {project: project, balance: balance}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
results = {"status": 0, "projects": result_list}
|
results = {"status": 0, "projects": result_list}
|
||||||
|
|
|
@ -13,4 +13,5 @@ else
|
||||||
json.type user["type"]
|
json.type user["type"]
|
||||||
json.name user["name"]
|
json.name user["name"]
|
||||||
json.image_url user["avatar_url"]
|
json.image_url user["avatar_url"]
|
||||||
|
json.blockchain_perc user.contribution_perc(project)
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
total_count = @contributors.size
|
total_count = @contributors.size
|
||||||
json.list @contributors.each do |contributor|
|
json.list @contributors.each do |contributor|
|
||||||
json.partial! 'contributor', locals: { contributor: contributor }
|
json.partial! 'contributor', locals: { contributor: contributor, project: @project }
|
||||||
end
|
end
|
||||||
json.total_count total_count
|
json.total_count total_count
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
json.total_count @total_count
|
||||||
|
json.projects @projects.each do |p|
|
||||||
|
json.partial! 'projects/detail', locals: { project: p[:project] }
|
||||||
|
json.balance p[:balance]
|
||||||
|
end
|
Loading…
Reference in New Issue