From 72a4549fe9db5766691130d861f54c985b01cefd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cxxq250=E2=80=9D?= <“xxq250@qq.com”> Date: Thu, 4 Aug 2022 17:02:25 +0800 Subject: [PATCH] =?UTF-8?q?fixed=20reposyncer=20jobs=20=E5=88=86=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/ob_repository_syncs_controller.rb | 8 +++++++- app/services/ob_repository_sync/api_service.rb | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/controllers/ob_repository_syncs_controller.rb b/app/controllers/ob_repository_syncs_controller.rb index 344a58355..9a0471c02 100644 --- a/app/controllers/ob_repository_syncs_controller.rb +++ b/app/controllers/ob_repository_syncs_controller.rb @@ -44,7 +44,13 @@ class ObRepositorySyncsController < ApplicationController tip_exception "该项目未创建同步任务" if @ob_repository_sync.blank? service = ObRepositorySync::ApiService.new(@ob_repository_sync.name) res = service.get_projects_jobs - render_ok(count: res["data"]["total"], data: res["data"]["list"]) + data = res["data"]["list"] + if params[:type] && params[:type].to_s.downcase == "github" + data = data.select { |row| row["github_branch"].present? } + elsif params[:type] && params[:type].to_s.downcase == "gitee" + data = data.select { |row| row["gitee_branch"].present? } + end + render_ok(count: res["data"]["total"], data: data) end def create_jobs diff --git a/app/services/ob_repository_sync/api_service.rb b/app/services/ob_repository_sync/api_service.rb index 787383432..b059f7995 100644 --- a/app/services/ob_repository_sync/api_service.rb +++ b/app/services/ob_repository_sync/api_service.rb @@ -43,7 +43,7 @@ class ObRepositorySync::ApiService < ApplicationService end def get_projects_jobs - url = URI("#{domain}/cerobot/projects/#{@project_name}/jobs") + url = URI("#{domain}/cerobot/projects/#{@project_name}/jobs?pageSize=100&pageNum=1") http = Net::HTTP.new(url.host, url.port) request = Net::HTTP::Get.new(url) request["Content-Type"] = "application/json"