Skip to content

Commit

Permalink
Check the presence of staging project
Browse files Browse the repository at this point in the history
  • Loading branch information
rubhanazeem committed Dec 5, 2024
1 parent b4bfd94 commit 94b2fb7
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/api/app/controllers/concerns/webui/requests_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ def filter_by_involvement(filter_involvement, project = nil, package = nil)
end

def filter_by_involvement_for_project(filter_by_involvement, project)
binding.pry
target = BsRequest.with_actions.joins(:reviews).where(reviews: { by_project: project.name })
source = BsRequest.with_actions.joins(:reviews).where(reviews: { by_project: project.name })
project = root_project(project)
target = BsRequest.with_actions.where(bs_request_actions: { target_project: project.name })
source = BsRequest.with_actions.where(bs_request_actions: { source_project: project.name })
case filter_by_involvement
when 'all'
target.or(source)
Expand All @@ -61,8 +61,9 @@ def filter_by_involvement_for_project(filter_by_involvement, project)
end

def filter_by_involvement_for_package(filter_by_involvement, project, package)
target = BsRequest.with_actions.joins(:reviews).where(reviews: { by_project: project.name, by_package: package.name })
source = BsRequest.with_actions.joins(:reviews).where(reviews: { by_project: project.name, by_package: package.name })
project = root_project(project)
target = BsRequest.with_actions.where(bs_request_actions: { target_project: project.name, target_package: package.name })
source = BsRequest.with_actions.where(bs_request_actions: { source_project: project.name, source_package: package.name })
case filter_by_involvement
when 'all'
target.or(source)
Expand All @@ -72,4 +73,12 @@ def filter_by_involvement_for_package(filter_by_involvement, project, package)
source
end
end

private

def root_project(project)
return project unless project.staging_project?

project.staging_workflow.project
end
end

0 comments on commit 94b2fb7

Please sign in to comment.