diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 6aee4b584..1b51e3b12 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -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 diff --git a/app/models/concerns/watchable.rb b/app/models/concerns/watchable.rb index 9eb0172d7..dc2b67f67 100644 --- a/app/models/concerns/watchable.rb +++ b/app/models/concerns/watchable.rb @@ -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) diff --git a/app/queries/blockchain/balance_query.rb b/app/queries/blockchain/balance_query.rb index 669370a54..a1bb76eea 100644 --- a/app/queries/blockchain/balance_query.rb +++ b/app/queries/blockchain/balance_query.rb @@ -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} diff --git a/app/views/repositories/_contributor.json.jbuilder b/app/views/repositories/_contributor.json.jbuilder index 56fa9ce86..2efaa0073 100644 --- a/app/views/repositories/_contributor.json.jbuilder +++ b/app/views/repositories/_contributor.json.jbuilder @@ -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 diff --git a/app/views/repositories/contributors.json.jbuilder b/app/views/repositories/contributors.json.jbuilder index 2fb6abae8..4534de693 100644 --- a/app/views/repositories/contributors.json.jbuilder +++ b/app/views/repositories/contributors.json.jbuilder @@ -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 diff --git a/app/views/users/blockchain_balance.json.jbuilder b/app/views/users/blockchain_balance.json.jbuilder new file mode 100644 index 000000000..83293cf09 --- /dev/null +++ b/app/views/users/blockchain_balance.json.jbuilder @@ -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 \ No newline at end of file