Class: Nexo::SynchronizableChangedJob

Inherits:
BaseJob
  • Object
show all
Includes:
GoodJob::ActiveJobExtensions::Concurrency
Defined in:
app/jobs/nexo/synchronizable_changed_job.rb

Instance Method Summary collapse

Instance Method Details

#perform(synchronizable, excluded_folders: []) ⇒ Object

Raises:

  • (ActiveRecord::PreparedStatementCacheExpired)


20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/jobs/nexo/synchronizable_changed_job.rb', line 20

def perform(synchronizable, excluded_folders: [])
  # Maybe restrict this query to a more specific scope
  scope = Folder.kept
  if excluded_folders.any?
    scope = scope.where.not(id: excluded_folders)
  end
  Nexo.logger.debug("Processing #{scope.count} folders")

  # TODO: test
  GoodJob::Bulk.enqueue do
    scope.each do |folder|
      folder_service.find_element_and_sync(folder, synchronizable)
    end
  end
end