Class: Tasks::Dwc::DashboardController

Inherits:
ApplicationController
  • Object
show all
Includes:
TaskControllerConfiguration
Defined in:
app/controllers/tasks/dwc/dashboard_controller.rb

Instance Method Summary collapse

Methods included from TaskControllerConfiguration

#set_is_task_controller

Instance Method Details

#create_indexObject

TODO: throttle to 5k.



30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/controllers/tasks/dwc/dashboard_controller.rb', line 30

def create_index
  q = ::Queries::CollectionObject::Filter.new(params)
  q.project_id = nil

  if q.all(true)
    q.project_id = sessions_current_project_id
     = ::Export::Dwca.build_index_async(CollectionObject, q.all)
    render json: , status: :ok
  else
    render json: {}, status: :unprocessable_entity
  end
end

#generate_downloadObject

/tasks/dwc/dashboard/generate_download.json !! Run rails jobs:work in the terminal to complete builds



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/controllers/tasks/dwc/dashboard_controller.rb', line 10

def generate_download
  q = ::Queries::DwcOccurrence::Filter.new(params)

  @download = ::Export::Dwca.download_async(
    q.all, request.url,
    predicate_extensions: predicate_extension_params,
    taxonworks_extensions: taxonworks_extension_params,
    extension_scopes: {
      biological_associations: (params[:biological_associations_extension] ?
      ::Queries::BiologicalAssociation::Filter.new(
        collection_object_query: ::Queries::CollectionObject::Filter.new(
          dwc_occurrence_query: q.params
        ).params
      ).all.to_sql : nil)
    }
  )
  render '/downloads/show'
end

#indexObject

DWC_TASK



5
6
# File 'app/controllers/tasks/dwc/dashboard_controller.rb', line 5

def index
end

#index_versionsObject



43
44
45
# File 'app/controllers/tasks/dwc/dashboard_controller.rb', line 43

def index_versions
  render json: ::Export::Dwca::INDEX_VERSION, status: :ok
end

#predicate_extension_paramsObject (private)



53
54
55
# File 'app/controllers/tasks/dwc/dashboard_controller.rb', line 53

def predicate_extension_params
  a = params.permit(collecting_event_predicate_id: [], collection_object_predicate_id: []).to_h.symbolize_keys
end

#taxonworks_extension_methodsObject



47
48
49
# File 'app/controllers/tasks/dwc/dashboard_controller.rb', line 47

def taxonworks_extension_methods
  render json: ::CollectionObject::DwcExtensions::TaxonworksExtensions::EXTENSION_FIELDS, status: :ok
end

#taxonworks_extension_paramsObject (private)



57
58
59
60
# File 'app/controllers/tasks/dwc/dashboard_controller.rb', line 57

def taxonworks_extension_params
  a = params.permit(taxonworks_extension_methods: []).dig(:taxonworks_extension_methods)
  a ? a.map(&:to_sym) : {}
end