diff options
author | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2017-06-23 22:28:53 +0300 |
---|---|---|
committer | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2017-06-23 22:35:05 +0300 |
commit | e9732404f93558fb9cbfc4651b56ab3e7566a373 (patch) | |
tree | 7b48331c62bef031ad13bf0aa232f6da9c9af84c /app/models | |
parent | 087c1056d438aaa9e471f5c4c233a0bfd4e6b541 (diff) |
Break Project#perform_housekeeping in two methods
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/project.rb | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/app/models/project.rb b/app/models/project.rb index 3bc95b1afcb..f7db8c2bede 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -350,7 +350,10 @@ class Project < ActiveRecord::Base project.run_after_commit { add_import_job } end - after_transition started: :finished, do: :perform_housekeeping + after_transition started: :finished do |project, _| + project.reset_cache_and_import_attrs + project.perform_housekeeping + end end class << self @@ -502,17 +505,22 @@ class Project < ActiveRecord::Base end end + def reset_cache_and_import_attrs + run_after_commit do + ProjectCacheWorker.perform_async(self.id) + end + + remove_import_data + end + def perform_housekeeping run_after_commit do begin - ProjectCacheWorker.perform_async(self.id) Projects::HousekeepingService.new(self).execute rescue Projects::HousekeepingService::LeaseTaken => e Rails.logger.info("Could not perform housekeeping for project #{self.path_with_namespace} (#{self.id}): #{e}") end end - - remove_import_data end def remove_import_data |