Skip to content

Commit

Permalink
Move common method to Workflow::Step model
Browse files Browse the repository at this point in the history
As we did we other common methods, we extract the code from
BranchPackageStep and LinkPackageStep to Step model.

That's is not the final place, we have a plan to find a better
architecture for this.
  • Loading branch information
saraycp committed Sep 16, 2021
1 parent a334e38 commit 1517863
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 19 deletions.
11 changes: 11 additions & 0 deletions src/api/app/models/workflow/step.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,5 +145,16 @@ def workflow_architectures(repository, filters)

architectures
end

def report_to_scm(workflow_filters)
workflow_repositories(target_project_name, workflow_filters).each do |repository|
# TODO: Fix n+1 queries
workflow_architectures(repository, workflow_filters).each do |architecture|
# We cannot report multibuild flavors here... so they will be missing from the initial report
SCMStatusReporter.new({ project: target_project_name, package: target_package_name, repository: repository.name, arch: architecture.name },
scm_webhook.payload, @token.scm_token).call
end
end
end
end
# rubocop:enable Metrics/ClassLength
9 changes: 1 addition & 8 deletions src/api/app/models/workflow/step/branch_package_step.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,7 @@ def branch_package(workflow_filters = {})

create_or_update_subscriptions(branched_package, workflow_filters)

workflow_repositories(target_project_name, workflow_filters).each do |repository|
# TODO: Fix n+1 queries
workflow_architectures(repository, workflow_filters).each do |architecture|
# We cannot report multibuild flavors here... so they will be missing from the initial report
SCMStatusReporter.new({ project: target_project_name, package: target_package_name, repository: repository.name, arch: architecture.name },
scm_webhook.payload, @token.scm_token).call
end
end
report_to_scm(workflow_filters)

branched_package
end
Expand Down
11 changes: 0 additions & 11 deletions src/api/app/models/workflow/step/link_package_step.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,4 @@ def link_xml(opts = {})
# "<link package=\"foo\" project=\"bar\" />"
Nokogiri::XML::Builder.new { |x| x.link(opts) }.doc.root.to_s
end

def report_to_scm(workflow_filters)
workflow_repositories(target_project_name, workflow_filters).each do |repository|
# TODO: Fix n+1 queries
workflow_architectures(repository, workflow_filters).each do |architecture|
# We cannot report multibuild flavors here... so they will be missing from the initial report
SCMStatusReporter.new({ project: target_project_name, package: target_package_name, repository: repository.name, arch: architecture.name },
scm_webhook.payload, @token.scm_token).call
end
end
end
end

0 comments on commit 1517863

Please sign in to comment.