新增:历史记录分页
This commit is contained in:
parent
fd48f00097
commit
e0b1d6fbb6
|
@ -114,7 +114,7 @@ class Api::V1::Projects::SyncRepositoriesController < Api::V1::BaseController
|
||||||
def history
|
def history
|
||||||
return render_error("请输入正确的同步分支ID") unless params[:reposync_branch_ids]
|
return render_error("请输入正确的同步分支ID") unless params[:reposync_branch_ids]
|
||||||
@branch = SyncRepositoryBranch.find_by(reposync_branch_id: params[:reposync_branch_ids].split(",")[0])
|
@branch = SyncRepositoryBranch.find_by(reposync_branch_id: params[:reposync_branch_ids].split(",")[0])
|
||||||
_, @reposync_branch_logs, _ = Reposync::GetLogsService.call(nil, params[:reposync_branch_ids], page, limit)
|
_, @reposync_branch_logs, @total_count, _ = Reposync::GetLogsService.call(nil, params[:reposync_branch_ids], page, limit)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -95,4 +95,21 @@ class Reposync::ClientService < ApplicationService
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def render_list_response(response)
|
||||||
|
status = response.status
|
||||||
|
body = JSON.parse(response&.body)
|
||||||
|
|
||||||
|
log_error(status, body)
|
||||||
|
|
||||||
|
if status == 200
|
||||||
|
if body["code_status"].to_i == 0
|
||||||
|
return [body["code_status"], body["data"], body["total"], body["msg"]]
|
||||||
|
else
|
||||||
|
puts "[reposync][ERROR] code: #{body["code_status"]}"
|
||||||
|
puts "[reposync][ERROR] message: #{body["msg"]}"
|
||||||
|
return [body["code_status"], body["data"], body["total"], body["msg"]]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
|
@ -11,7 +11,7 @@ class Reposync::GetLogsService < Reposync::ClientService
|
||||||
|
|
||||||
def call
|
def call
|
||||||
result = get(url, request_params)
|
result = get(url, request_params)
|
||||||
response = render_response(result)
|
response = render_list_response(result)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
json.total_count @reposync_branch_logs.count
|
json.total_count @total_count
|
||||||
json.gitlink_branch_name @branch&.gitlink_branch_name
|
json.gitlink_branch_name @branch&.gitlink_branch_name
|
||||||
json.external_type @branch&.sync_repository&.type
|
json.external_type @branch&.sync_repository&.type
|
||||||
json.external_branch_name @branch&.external_branch_name
|
json.external_branch_name @branch&.external_branch_name
|
||||||
|
|
Loading…
Reference in New Issue