新增:历史记录分页

This commit is contained in:
yystopf 2024-05-09 13:41:46 +08:00
parent fd48f00097
commit e0b1d6fbb6
4 changed files with 20 additions and 3 deletions

View File

@ -114,7 +114,7 @@ class Api::V1::Projects::SyncRepositoriesController < Api::V1::BaseController
def history
return render_error("请输入正确的同步分支ID") unless params[:reposync_branch_ids]
@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
private

View File

@ -95,4 +95,21 @@ class Reposync::ClientService < ApplicationService
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

View File

@ -11,7 +11,7 @@ class Reposync::GetLogsService < Reposync::ClientService
def call
result = get(url, request_params)
response = render_response(result)
response = render_list_response(result)
end
private

View File

@ -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.external_type @branch&.sync_repository&.type
json.external_branch_name @branch&.external_branch_name