Class: Tasks::Dwc::DashboardController

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

Instance Method Summary collapse

Methods included from CollectionObjects::FilterParams

#collection_object_api_params, #collection_object_filter_params, #filtered_collection_objects

Methods included from TaskControllerConfiguration

#set_is_task_controller

Instance Method Details

#create_indexObject



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

def create_index
  if collection_object_filter_params.to_h.any?
     = ::Export::Dwca.build_index_async(CollectionObject, filtered_collection_objects)
    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



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

def generate_download
  # TODO: to support scoping by other filters
  # we will have to scope all filter params throughout by their target base
  # e.g. collection_object[param]
  a = nil
  if collection_object_filter_params.to_h.any?
    a = DwcOccurrence.by_collection_object_filter(
      filter_scope: filtered_collection_objects,
      project_id: sessions_current_project_id)
  else
    a = DwcOccurrence.where(project_id: sessions_current_project_id)
    if params[:dwc_occurrence_start_date]
      a = a.where('dwc_occurrences.updated_at < ? and dwc_occurrences.updated_at > ?', params[:dwc_occurrence_start_date], params[:dwc_occurrence_end_date])
    end
  end

  @download = ::Export::Dwca.download_async(a, request.url)
  render '/downloads/show'
end

#indexObject

DWC_TASK



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

def index
end

#index_versionsObject



40
41
42
# File 'app/controllers/tasks/dwc/dashboard_controller.rb', line 40

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