Skip to content

Commit

Permalink
Refactor method project_ready_to_autoclean?
Browse files Browse the repository at this point in the history
Order the validations by complexity
  • Loading branch information
vpereira committed Oct 26, 2020
1 parent 8d6e177 commit 2bc0791
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/api/app/jobs/project_create_auto_cleanup_requests_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,6 @@ def perform
private

def autoclean_project(prj)
# open requests do block the cleanup
return if open_requests_count(prj.name).positive?

# check the time in project attribute
return unless project_ready_to_autoclean?(prj)

begin
Expand Down Expand Up @@ -84,7 +80,9 @@ def create_request(project:, description: DESCRIPTION, cleanup_time: 5)

def project_ready_to_autoclean?(project)
# project may be locked?
return false if project.nil? || project.is_locked?
return false if project.is_locked?
# open requests do block the cleanup
return false if open_requests_count(project.name).positive?
return false unless project.check_weak_dependencies?

true
Expand Down

0 comments on commit 2bc0791

Please sign in to comment.