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