fixed 组织流水线列表接口,组织内所有仓库,分组显示
This commit is contained in:
parent
033c5cf191
commit
aed452e144
|
@ -5,7 +5,7 @@ class Api::Pm::PipelinesController < Api::Pm::BaseController
|
||||||
def index
|
def index
|
||||||
@owner = Owner.find_by(login: params[:owner_id].to_s) || Owner.find_by(id: params[:owner_id].to_s)
|
@owner = Owner.find_by(login: params[:owner_id].to_s) || Owner.find_by(id: params[:owner_id].to_s)
|
||||||
tip_exception('组织未找到') if @owner.blank?
|
tip_exception('组织未找到') if @owner.blank?
|
||||||
project_ids = @owner.projects.ids
|
@project_ids = @owner.projects.ids
|
||||||
project_gpids = @owner.projects.pluck(:gpid)
|
project_gpids = @owner.projects.pluck(:gpid)
|
||||||
action_runs = Gitea::ActionRun.where(owner_id: @owner.gitea_uid)
|
action_runs = Gitea::ActionRun.where(owner_id: @owner.gitea_uid)
|
||||||
group_data = action_runs.where(status: [1,2]).group(:workflow_id, :status).count
|
group_data = action_runs.where(status: [1,2]).group(:workflow_id, :status).count
|
||||||
|
@ -64,7 +64,8 @@ class Api::Pm::PipelinesController < Api::Pm::BaseController
|
||||||
end
|
end
|
||||||
Rails.logger.info("@run_result======#{@run_result}")
|
Rails.logger.info("@run_result======#{@run_result}")
|
||||||
@disabled_workflows = Gitea::RepoUnit.where(repo_id: project_gpids, type: 10).where("config is not null")
|
@disabled_workflows = Gitea::RepoUnit.where(repo_id: project_gpids, type: 10).where("config is not null")
|
||||||
@pipelines = Action::Pipeline.where(project_id: project_ids).order(updated_at: :desc)
|
@pipelines = Action::Pipeline.where(project_id: @project_ids).order(updated_at: :desc)
|
||||||
|
@pipelines = @pipelines
|
||||||
@pipelines = paginate @pipelines
|
@pipelines = paginate @pipelines
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,24 @@
|
||||||
json.status 0
|
json.status 0
|
||||||
json.message "success"
|
json.message "success"
|
||||||
|
json.projects @project_ids.each do |project_id|
|
||||||
json.pipelines @pipelines.each do |pipeline|
|
json.id project_id
|
||||||
json.extract! pipeline, :id, :pipeline_name, :pipeline_status, :description, :file_name, :is_graphic_design,
|
project = Project.find_by(id: project_id)
|
||||||
:repo_name, :repo_identifier, :branch, :event, :sha, :disable, :json, :yaml, :created_at, :updated_at
|
if project.present?
|
||||||
repo_config = @disabled_workflows.select { |config| config.repo_id = pipeline.project.gpid }
|
json.owner project.owner.name
|
||||||
if repo_config.present?
|
json.identifier project.identifier
|
||||||
json.disable JSON.parse(repo_config.first.config)["DisabledWorkflows"].to_s.include?(pipeline.file_name.to_s.gsub(".gitea/workflows/", ""))
|
json.name project.name
|
||||||
else
|
json.url "#{Rails.application.config_for(:configuration)['platform_url']}/#{project.owner.name}/#{project.identifier}"
|
||||||
json.disable pipeline.disable
|
json.pipelines @pipelines.select { |p| p.repo_id == project_id }.each do |pipeline|
|
||||||
|
json.extract! pipeline, :id, :project_id, :pipeline_name, :pipeline_status, :description, :file_name, :is_graphic_design,
|
||||||
|
:repo_name, :repo_identifier, :branch, :event, :sha, :disable, :json, :yaml, :created_at, :updated_at
|
||||||
|
repo_config = @disabled_workflows.select { |config| config.repo_id = pipeline.project.gpid }
|
||||||
|
if repo_config.present?
|
||||||
|
json.disable JSON.parse(repo_config.first.config)["DisabledWorkflows"].to_s.include?(pipeline.file_name.to_s.gsub(".gitea/workflows/", ""))
|
||||||
|
else
|
||||||
|
json.disable pipeline.disable
|
||||||
|
end
|
||||||
|
json.pipeline_type pipeline.pipeline_type
|
||||||
|
json.run_data @run_result.select { |result| result[:filename] == pipeline.file_name }.first
|
||||||
|
end
|
||||||
end
|
end
|
||||||
json.pipeline_type pipeline.pipeline_type
|
|
||||||
json.run_data @run_result.select { |result| result[:filename] == pipeline.file_name }.first
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue