新增:code_stats分页
This commit is contained in:
parent
913eb62923
commit
9fe3b5ae3e
|
@ -2,7 +2,7 @@ class Api::V1::Projects::CodeStatsController < Api::V1::BaseController
|
||||||
before_action :require_public_and_member_above, only: [:index]
|
before_action :require_public_and_member_above, only: [:index]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@result_object = Api::V1::Projects::CodeStats::ListService.call(@project, {ref: params[:ref]}, current_user&.gitea_token)
|
@result_object = Api::V1::Projects::CodeStats::ListService.call(@project, {page: page, limit, limit, ref: params[:ref]}, current_user&.gitea_token)
|
||||||
puts @result_object
|
puts @result_object
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -1,6 +1,6 @@
|
||||||
class Api::V1::Projects::CodeStats::ListService < ApplicationService
|
class Api::V1::Projects::CodeStats::ListService < ApplicationService
|
||||||
|
|
||||||
attr_reader :project, :ref, :owner, :repo, :token
|
attr_reader :project, :ref, :owner, :repo, :token, :page, :limit
|
||||||
attr_accessor :gitea_data
|
attr_accessor :gitea_data
|
||||||
|
|
||||||
def initialize(project, params, token=nil)
|
def initialize(project, params, token=nil)
|
||||||
|
@ -9,6 +9,8 @@ class Api::V1::Projects::CodeStats::ListService < ApplicationService
|
||||||
@owner = project&.owner.login
|
@owner = project&.owner.login
|
||||||
@repo = project&.identifier
|
@repo = project&.identifier
|
||||||
@token = token
|
@token = token
|
||||||
|
@page = params[:page]
|
||||||
|
@limit = params[:limit]
|
||||||
end
|
end
|
||||||
|
|
||||||
def call
|
def call
|
||||||
|
@ -20,7 +22,9 @@ class Api::V1::Projects::CodeStats::ListService < ApplicationService
|
||||||
private
|
private
|
||||||
def request_params
|
def request_params
|
||||||
param = {
|
param = {
|
||||||
access_token: token
|
access_token: token,
|
||||||
|
page: page,
|
||||||
|
limit: limit
|
||||||
}
|
}
|
||||||
param.merge!(ref: ref) if ref.present?
|
param.merge!(ref: ref) if ref.present?
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
json.author_count @result_object["author_count"]
|
json.total_count @result_object[:total_data].to_i
|
||||||
json.commit_count @result_object["commit_count"]
|
json.author_count @result_object[:data]["author_count"]
|
||||||
json.change_files @result_object["change_files"]
|
json.commit_count @result_object[:data]["commit_count"]
|
||||||
json.additions @result_object["additions"]
|
json.change_files @result_object[:data]["change_files"]
|
||||||
json.deletions @result_object["deletions"]
|
json.additions @result_object[:data]["additions"]
|
||||||
json.commit_count_in_all_branches @result_object["commit_count_in_all_branches"]
|
json.deletions @result_object[:data]["deletions"]
|
||||||
json.authors @result_object["authors"].each do |author|
|
json.commit_count_in_all_branches @result_object[:data]["commit_count_in_all_branches"]
|
||||||
|
json.authors @result_object[:data]["authors"].each do |author|
|
||||||
json.author do
|
json.author do
|
||||||
json.partial! 'api/v1/users/commit_user_email', locals: { user: render_cache_commit_author(author), name: author['name'], email: author['email'] }
|
json.partial! 'api/v1/users/commit_user_email', locals: { user: render_cache_commit_author(author), name: author['name'], email: author['email'] }
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue