Class: Tasks::Otus::FilterController

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

Instance Method Summary (collapse)

Methods included from TaskControllerConfiguration

#set_is_task_controller

Instance Method Details

- (Object) download



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/controllers/tasks/otus/filter_controller.rb', line 16

def download
  scope = DwcOccurrence.collection_objects_join
            .where(dwc_occurrence_object_id: otus.pluck(:id)) # !! see if we can get rid of pluck, shouldn't need it, but maybe complex join is not collapsabele to collection object id
            .where(project_id: sessions_current_project_id)
            .order('dwc_occurrences.id')

  # If failing remove begin/ensure/end to report Raised errors
  begin
    data = Dwca::Packer::Data.new(scope)
    send_data(data.getzip, type: 'application/zip', filename: data.filename)
  ensure
    data.cleanup
  end
end

- (Object) filter_params (protected)



58
59
60
61
62
63
# File 'app/controllers/tasks/otus/filter_controller.rb', line 58

def filter_params
  params.permit(
    :drawn_area_shape, :taxon_name_id, :descendants,
    :and_or_select, :rank_class, :page,
    :verbatim_author_string, author_ids: [], geographic_area_ids: [], selection_objetcs: [])
end

- (Object) find

POST



12
13
14
# File 'app/controllers/tasks/otus/filter_controller.rb', line 12

def find
  @otus = otus.order('otus.id').page(params[:page])
end

- (Object) index

GET



7
8
9
# File 'app/controllers/tasks/otus/filter_controller.rb', line 7

def index
  @otus = Otu.none
end

- (Object) otus (protected)



53
54
55
56
# File 'app/controllers/tasks/otus/filter_controller.rb', line 53

def otus
  Queries::Otu::Filter.new(filter_params).result
      .with_project_id(sessions_current_project_id)
end

- (Object) set_area

GET



32
33
34
# File 'app/controllers/tasks/otus/filter_controller.rb', line 32

def set_area
  render json: {html: otus.count}
end

- (Object) set_author

GET



37
38
39
# File 'app/controllers/tasks/otus/filter_controller.rb', line 37

def set_author
  render json: {html: otus.count}
end

- (Object) set_nomen

GET



42
43
44
# File 'app/controllers/tasks/otus/filter_controller.rb', line 42

def set_nomen
  render json: {html: otus.count}
end

- (Object) set_verbatim

GET



47
48
49
# File 'app/controllers/tasks/otus/filter_controller.rb', line 47

def set_verbatim
  render json: {html: otus.count}
end