Skip to content

Commit

Permalink
Use query objects when possible
Browse files Browse the repository at this point in the history
  • Loading branch information
vpereira committed Jul 9, 2021
1 parent a83d008 commit 722c920
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/api/app/jobs/project_create_auto_cleanup_requests_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,12 @@ def project_ready_to_autoclean?(project)
true
end

def open_requests_count(project)
def open_requests_count(project_name)
OpenRequestsWithProjectAsSourceOrTargetFinder.new(relation, project_name).call.count
end

def relation
BsRequest.in_states([:new, :review, :declined])
.joins(:bs_request_actions)
.where('bs_request_actions.target_project = ? OR bs_request_actions.source_project = ?', project, project)
.count
end
end

0 comments on commit 722c920

Please sign in to comment.