fixed reposyncer job任务增加分页
This commit is contained in:
parent
13472b2311
commit
467d722d25
|
@ -34,7 +34,7 @@ class ObRepositorySyncsController < ApplicationController
|
||||||
def delete
|
def delete
|
||||||
service = ObRepositorySync::ApiService.new(@ob_repository_sync.name)
|
service = ObRepositorySync::ApiService.new(@ob_repository_sync.name)
|
||||||
res = service.delete_project @ob_repository_sync.sync_id
|
res = service.delete_project @ob_repository_sync.sync_id
|
||||||
tip_exception "保存失败: #{res["msg"]}" if res["code"].to_s != "200"
|
tip_exception "删除失败: #{res["msg"]}" if res["code"].to_s != "200"
|
||||||
if res["code"].to_s == "200"
|
if res["code"].to_s == "200"
|
||||||
@ob_repository_sync.destroy!
|
@ob_repository_sync.destroy!
|
||||||
end
|
end
|
||||||
|
@ -43,14 +43,17 @@ class ObRepositorySyncsController < ApplicationController
|
||||||
|
|
||||||
def jobs
|
def jobs
|
||||||
tip_exception "该项目未创建同步任务" if @ob_repository_sync.blank?
|
tip_exception "该项目未创建同步任务" if @ob_repository_sync.blank?
|
||||||
|
page = params[:page] || 1
|
||||||
|
limit = params[:limit] || 10
|
||||||
service = ObRepositorySync::ApiService.new(@ob_repository_sync.name)
|
service = ObRepositorySync::ApiService.new(@ob_repository_sync.name)
|
||||||
res = service.get_projects_jobs
|
source = ""
|
||||||
data = res["data"]["list"]
|
|
||||||
if params[:type] && params[:type].to_s.downcase == "github"
|
if params[:type] && params[:type].to_s.downcase == "github"
|
||||||
data = data.select { |row| row["github_branch"].present? }
|
source = "github_branch"
|
||||||
elsif params[:type] && params[:type].to_s.downcase == "gitee"
|
elsif params[:type] && params[:type].to_s.downcase == "gitee"
|
||||||
data = data.select { |row| row["gitee_branch"].present? }
|
source = "gitee_branch"
|
||||||
end
|
end
|
||||||
|
res = service.get_projects_jobs(source, page, limit)
|
||||||
|
data = res["data"]["list"]
|
||||||
render_ok(count: res["data"]["total"], data: data)
|
render_ok(count: res["data"]["total"], data: data)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -83,7 +86,7 @@ class ObRepositorySyncsController < ApplicationController
|
||||||
tip_exception "缺少参数job_id" if params[:job_id].blank?
|
tip_exception "缺少参数job_id" if params[:job_id].blank?
|
||||||
service = ObRepositorySync::ApiService.new(@ob_repository_sync.name)
|
service = ObRepositorySync::ApiService.new(@ob_repository_sync.name)
|
||||||
res = service.delete_job params[:job_id]
|
res = service.delete_job params[:job_id]
|
||||||
tip_exception "保存失败: #{res["msg"]}" if res["code"].to_s != "200"
|
tip_exception "删除失败: #{res["msg"]}" if res["code"].to_s != "200"
|
||||||
job = ObRepositorySyncJob.find_by(ob_repository_sync_id: @ob_repository_sync.id, job_id: params[:job_id])
|
job = ObRepositorySyncJob.find_by(ob_repository_sync_id: @ob_repository_sync.id, job_id: params[:job_id])
|
||||||
job.destroy! if job.present?
|
job.destroy! if job.present?
|
||||||
render_ok
|
render_ok
|
||||||
|
|
|
@ -42,8 +42,8 @@ class ObRepositorySync::ApiService < ApplicationService
|
||||||
res
|
res
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_projects_jobs
|
def get_projects_jobs(source, pageNum = 1, pageSize = 100)
|
||||||
url = URI("#{domain}/cerobot/projects/#{@project_name}/jobs?pageSize=100&pageNum=1")
|
url = URI("#{domain}/cerobot/projects/#{@project_name}/jobs?pageSize=#{pageSize}&pageNum=#{pageNum}&source=#{source}")
|
||||||
http = Net::HTTP.new(url.host, url.port)
|
http = Net::HTTP.new(url.host, url.port)
|
||||||
request = Net::HTTP::Get.new(url)
|
request = Net::HTTP::Get.new(url)
|
||||||
request["Content-Type"] = "application/json"
|
request["Content-Type"] = "application/json"
|
||||||
|
|
Loading…
Reference in New Issue