|
|
|
@@ -34,7 +34,7 @@ class ObRepositorySyncsController < ApplicationController |
|
|
|
def delete |
|
|
|
service = ObRepositorySync::ApiService.new(@ob_repository_sync.name) |
|
|
|
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" |
|
|
|
@ob_repository_sync.destroy! |
|
|
|
end |
|
|
|
@@ -43,14 +43,17 @@ class ObRepositorySyncsController < ApplicationController |
|
|
|
|
|
|
|
def jobs |
|
|
|
tip_exception "该项目未创建同步任务" if @ob_repository_sync.blank? |
|
|
|
page = params[:page] || 1 |
|
|
|
limit = params[:limit] || 10 |
|
|
|
service = ObRepositorySync::ApiService.new(@ob_repository_sync.name) |
|
|
|
res = service.get_projects_jobs |
|
|
|
data = res["data"]["list"] |
|
|
|
source = "" |
|
|
|
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" |
|
|
|
data = data.select { |row| row["gitee_branch"].present? } |
|
|
|
source = "gitee_branch" |
|
|
|
end |
|
|
|
res = service.get_projects_jobs(source, page, limit) |
|
|
|
data = res["data"]["list"] |
|
|
|
render_ok(count: res["data"]["total"], data: data) |
|
|
|
end |
|
|
|
|
|
|
|
@@ -83,7 +86,7 @@ class ObRepositorySyncsController < ApplicationController |
|
|
|
tip_exception "缺少参数job_id" if params[:job_id].blank? |
|
|
|
service = ObRepositorySync::ApiService.new(@ob_repository_sync.name) |
|
|
|
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.destroy! if job.present? |
|
|
|
render_ok |
|
|
|
|