app/jobs/dwca_create_download_job.rb
class DwcaCreateDownloadJob < ApplicationJob
queue_as :dwca_export
# @param core_scope [String, ActiveRecord::Relation]
# String of SQL generated from the scope
# SQL must return a list of DwcOccurrence records
# take a download, and a list of scopes, and save the result to the download, that's all
# @return
# # TODO: handle extension scopes
def perform(download, core_scope: nil, extension_scopes: {biological_associations: nil, media: nil}, predicate_extensions: {}, taxonworks_extensions: [])
begin
begin
d = ::Export::Dwca::Data.new(core_scope:, predicate_extensions:, extension_scopes:, taxonworks_extensions:)
d.package_download(download)
d
ensure
d.cleanup
end
rescue => ex
ExceptionNotifier.notify_exception(ex, data: { download: download&.id&.to_s } ) # otu: otu&.id&.to_s,
raise
end
end
end