Skip to content

Commit

Permalink
Use BsRequest FindFor query class to find bs_requests related to proj…
Browse files Browse the repository at this point in the history
…ects and packages
  • Loading branch information
rubhanazeem committed Dec 6, 2024
1 parent d6a276b commit edfbe93
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/api/app/controllers/concerns/webui/requests_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ def filter_by_involvement(filter_involvement, project = nil, package = nil)
end

def filter_by_involvement_for_project(filter_by_involvement, 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 })
target = BsRequest::FindFor::Project.new({project: project.name, source_or_target: 'target'}).all
source = BsRequest::FindFor::Project.new({project: project.name, source_or_target: 'source'}).all
case filter_by_involvement
when 'all'
target.or(source)
Expand All @@ -60,8 +60,8 @@ 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.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 })
target = BsRequest::FindFor::Project.new({project: project.name, package: package.name, source_or_target: 'target'}).all
source = BsRequest::FindFor::Project.new({project: project.name, package: package.name, source_or_target: 'source'}).all
case filter_by_involvement
when 'all'
target.or(source)
Expand Down
4 changes: 4 additions & 0 deletions src/api/app/models/bs_request/find_for/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ def quote(str)
def creator
@parameters[:creator]
end

def source_or_target
@parameters[:source_or_target]
end
end
end
end
8 changes: 6 additions & 2 deletions src/api/app/models/bs_request/find_for/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@ def all
@where_conditions = []
@where_values = []

bs_request_actions_conditions('source')
bs_request_actions_conditions('target')
if source_or_target.present?
bs_request_actions_conditions(source_or_target)
else
bs_request_actions_conditions('source')
bs_request_actions_conditions('target')
end

reviews_conditions

Expand Down

0 comments on commit edfbe93

Please sign in to comment.