Skip to content

Commit

Permalink
Make separate entries for multibuild packages
Browse files Browse the repository at this point in the history
  • Loading branch information
rubhanazeem committed Mar 26, 2024
1 parent 49f5b6a commit 0b20b3f
Showing 1 changed file with 19 additions and 23 deletions.
Expand Up @@ -9,33 +9,16 @@ def initialize(actions:)
def call
return [] if @actions.blank?

@actions.where(type: %i[submit maintenance_incident maintenance_release])
.map { |action| sources_from_action(action) }
.select { |sources| sources[:source_project].present? && sources[:source_package].present? }
.map do |sources|
build_results = package_build_results(sources[:source_package], sources[:source_project])
@actions.where(type: %i[submit maintenance_incident maintenance_release]).map do |action|
sources = sources_from_action(action)
next unless sources[:source_project].present? && sources[:source_package].present?

request_build_results(build_results, sources[:source_package], sources[:source_project])
end
.flatten
package_build_results(sources[:source_package], sources[:source_project])
end.flatten
end

private

def request_build_results(build_results, source_package, source_project)
build_results.map do |result_entry|
{
architecture: result_entry.architecture,
repository: result_entry.repository,
status: result_entry.code,
package_name: source_package.name,
project_name: source_project.name,
repository_status: result_entry.state,
is_repository_in_db: result_entry.is_repository_in_db
}
end
end

def project_from_action(action)
bs_request = BsRequest.find(action.bs_request_id)
# consider staging project
Expand All @@ -50,7 +33,20 @@ def sources_from_action(action)
end

def package_build_results(source_package, source_project)
source_package.buildresult(source_project, show_all: true).results.flat_map { |_k, v| v }
results = source_package.buildresult(source_project, show_all: true).results
results.flat_map do |pkg, build_results|
build_results.map do |result|
{
architecture: result.architecture,
repository: result.repository,
status: result.code,
package_name: pkg,
project_name: source_project.name,
repository_status: result.state,
is_repository_in_db: result.is_repository_in_db
}
end
end
end
end
end

0 comments on commit 0b20b3f

Please sign in to comment.