gitlink-forgeplus/app/views/api/pm/pipelines/index.json.jbuilder

31 lines
1.4 KiB
Ruby

json.status 0
json.message "success"
json.count @pipelines.total_count
json.projects @pipelines.map(&:project_id).uniq.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}"
pipelines = Action::Pipeline.where(project_id: project.id).order(updated_at: :desc)
json.pipelines pipelines.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
if pipeline.json.blank? && pipeline.yaml.blank?
json.run_data nil
else
json.run_data @run_result.select { |result| result[:repo_id] == project.gpid && result[:filename] == pipeline.file_name}.first
end
end
end
end