Class: Tasks::Dwc::DashboardController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Tasks::Dwc::DashboardController
- Defined in:
- app/controllers/tasks/dwc/dashboard_controller.rb
Instance Method Summary collapse
- #create_index ⇒ Object
-
#generate_download ⇒ Object
/tasks/dwc/dashboard/generate_download.json !! Run rails jobs:work in the terminal to complete builds.
-
#index ⇒ Object
DWC_TASK.
- #index_versions ⇒ Object
- #predicate_extension_params ⇒ Object private
Methods included from CollectionObjects::FilterParams
#collection_object_api_params, #collection_object_filter_params, #filtered_collection_objects
Methods included from TaskControllerConfiguration
Instance Method Details
#create_index ⇒ Object
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_download ⇒ Object
/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, predicate_extension_params: predicate_extension_params ) render '/downloads/show' end |
#index ⇒ Object
DWC_TASK
6 7 |
# File 'app/controllers/tasks/dwc/dashboard_controller.rb', line 6 def index end |
#index_versions ⇒ Object
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 |
#predicate_extension_params ⇒ Object (private)
46 47 48 |
# File 'app/controllers/tasks/dwc/dashboard_controller.rb', line 46 def predicate_extension_params params.permit(collecting_event_predicate_id: [], collection_object_predicate_id: [] ).transform_keys(&:to_sym).to_h end |