Skip to content

Instantly share code, notes, and snippets.

@mattvague
Created July 17, 2013 23:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattvague/6025606 to your computer and use it in GitHub Desktop.
Save mattvague/6025606 to your computer and use it in GitHub Desktop.
class BulkFileJob
@queue = :bulk
#-----------------------------------------------------------------------------
# Class methods
#-----------------------------------------------------------------------------
def self.perform(bulk_id)
new(bulk_id).perform
end
#-----------------------------------------------------------------------------
# Instance methods
#-----------------------------------------------------------------------------
def initialize(document_version_id)
@bulk_upload = BulkUpload::Base.find(bulk_id)
end
def perform
@bulk_upload.run
send_push_notification
end
# Sends a push notification notifying the the zip file has been processed
#
# @param id [Integer] id of Document
# @param file_url [String] OCR file url
def send_push_notification
return unless push_enabled?
Pusher['bulk-uploads'].trigger('change', {
id: @bulk_upload.id,
processed_at: @bulk_upload.processed_at,
document_ids: @bulk_upload.document_ids
})
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment