fixed 组织流水线运行数据控制

This commit is contained in:
xxq250 2025-04-21 15:53:04 +08:00
parent d3bc799263
commit 88415e256d
2 changed files with 49 additions and 48 deletions

View File

@ -16,11 +16,9 @@ class Api::Pm::PipelinesController < Api::Pm::BaseController
db_files = pipelines.pluck(:file_name)
@run_result = []
run_files.each do |file_info|
# file = file_info.workflow_id
file = file_info.workflow_id
project = Project.find_by(gpid: file_info.repo_id)
next if project.blank?
files = $gitea_client.get_repos_contents_by_owner_repo_filepath(project&.owner&.login, project&.identifier, ".gitea/workflows") rescue []
files.map { |i| i['name'] }.each do |file|
unless db_files.include?(".gitea/workflows/#{file}")
pipeline = Action::Pipeline.find_or_initialize_by(pipeline_name: file.to_s.gsub(".yml", "").gsub(".yaml", ""),
file_name: ".gitea/workflows/#{file}",
@ -67,7 +65,6 @@ class Api::Pm::PipelinesController < Api::Pm::BaseController
failure: failure
}.merge(last_action_run_json)
end
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)

View File

@ -19,7 +19,11 @@ json.projects @pipelines.map(&:project_id).uniq.each do |project_id|
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