forked from Trustie/forgeplus
新增:项目开发者接口
This commit is contained in:
parent
96e1021f3f
commit
7d11ecab11
|
|
@ -0,0 +1,11 @@
|
|||
class Api::V1::Projects::DevelopersController < Api::V1::BaseController
|
||||
def index
|
||||
@query_result = ActiveRecord::Base.connection.select_all("select user_id, count(*), count(DISTINCT project_id), (select count(1) from issues where issues.author_id = commit_logs.user_id) as issues_count from commit_logs group by user_id")
|
||||
@rows = kaminari_array_paginate(@query_result.rows)
|
||||
end
|
||||
|
||||
def count
|
||||
@query_result = ActiveRecord::Base.connection.select_all("select user_id, count(*), count(DISTINCT project_id), (select count(1) from issues where issues.author_id = commit_logs.user_id) as issues_count from commit_logs group by user_id")
|
||||
render_ok({count: @query_result.rows.count})
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
json.total_count @rows.total_count
|
||||
json.users @rows.each do |row|
|
||||
user = User.find(row[0])
|
||||
if user.blank?
|
||||
json.user nil
|
||||
else
|
||||
json.user do
|
||||
json.partial! "api/v1/users/simple_user", user: user
|
||||
end
|
||||
end
|
||||
json.commit_count row[1]
|
||||
json.project_count row[2]
|
||||
json.issues_count row[3]
|
||||
end
|
||||
Loading…
Reference in New Issue