fixed 组织流水线列表接口,组织内所有仓库,分组显示

This commit is contained in:
xxq250 2025-04-17 10:25:27 +08:00
parent 033c5cf191
commit aed452e144
2 changed files with 23 additions and 13 deletions

View File

@ -5,7 +5,7 @@ class Api::Pm::PipelinesController < Api::Pm::BaseController
def index
@owner = Owner.find_by(login: params[:owner_id].to_s) || Owner.find_by(id: params[:owner_id].to_s)
tip_exception('组织未找到') if @owner.blank?
project_ids = @owner.projects.ids
@project_ids = @owner.projects.ids
project_gpids = @owner.projects.pluck(:gpid)
action_runs = Gitea::ActionRun.where(owner_id: @owner.gitea_uid)
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
Rails.logger.info("@run_result======#{@run_result}")
@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
end

View File

@ -1,8 +1,15 @@
json.status 0
json.message "success"
json.pipelines @pipelines.each do |pipeline|
json.extract! pipeline, :id, :pipeline_name, :pipeline_status, :description, :file_name, :is_graphic_design,
json.projects @project_ids.each do |project_id|
json.id project_id
project = Project.find_by(id: project_id)
if project.present?
json.owner project.owner.name
json.identifier project.identifier
json.name project.name
json.url "#{Rails.application.config_for(:configuration)['platform_url']}/#{project.owner.name}/#{project.identifier}"
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?
@ -12,4 +19,6 @@ json.pipelines @pipelines.each do |pipeline|
end
json.pipeline_type pipeline.pipeline_type
json.run_data @run_result.select { |result| result[:filename] == pipeline.file_name }.first
end
end
end