| @@ -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.commit_count @result_object["commit_count"] | |||||
| json.change_files @result_object["change_files"] | |||||
| json.additions @result_object["additions"] | |||||
| json.deletions @result_object["deletions"] | |||||
| json.commit_count_in_all_branches @result_object["commit_count_in_all_branches"] | |||||
| json.authors @result_object["authors"].each do |author| | |||||
| json.total_count @result_object[:total_data].to_i | |||||
| json.author_count @result_object[:data]["author_count"] | |||||
| json.commit_count @result_object[:data]["commit_count"] | |||||
| json.change_files @result_object[:data]["change_files"] | |||||
| json.additions @result_object[:data]["additions"] | |||||
| json.deletions @result_object[:data]["deletions"] | |||||
| 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 | ||||