Module: Queries::Concerns::Notes
- Extended by:
- ActiveSupport::Concern
- Included in:
- AssertedDistribution::Filter, BiologicalAssociation::Filter, BiologicalAssociationsGraph::Filter, Queries::CollectingEvent::Filter, Queries::CollectionObject::Filter, Descriptor::Filter, FieldOccurrence::Filter, Loan::Filter, Observation::Filter, Otu::Filter, Person::Filter, Source::Filter, TaxonName::Filter
- Defined in:
- lib/queries/concerns/notes.rb
Overview
Helpers and facets for queries that reference Notes.
Test coverage is currently in spec/lib/queries/collection_object/filter_spec.rb.
Class Method Summary collapse
Instance Method Summary collapse
- #note_table ⇒ Arel::Table
- #note_text_facet ⇒ Object
- #notes_facet ⇒ Object
- #set_notes_params(params) ⇒ Object
Class Method Details
.merge_clauses ⇒ Object
42 43 44 45 46 47 |
# File 'lib/queries/concerns/notes.rb', line 42 def self.merge_clauses [ :note_text_facet, :notes_facet ] end |
.params ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/queries/concerns/notes.rb', line 9 def self.params [ :note_exact, :note_text, :notes ] end |
Instance Method Details
#note_table ⇒ Arel::Table
38 39 40 |
# File 'lib/queries/concerns/notes.rb', line 38 def note_table ::Note.arel_table end |
#note_text_facet ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/queries/concerns/notes.rb', line 49 def note_text_facet return nil if note_text.blank? if note_exact referenced_klass.joins(:notes).where(note_table[:text].eq(note_text)) else referenced_klass.joins(:notes).where( note_table[:text].matches('%' + note_text + '%') ) end end |
#notes_facet ⇒ Object
61 62 63 64 65 66 67 68 |
# File 'lib/queries/concerns/notes.rb', line 61 def notes_facet return nil if notes.nil? if notes referenced_klass.joins(:notes).distinct else referenced_klass.where.missing(:notes) end end |
#set_notes_params(params) ⇒ Object
31 32 33 34 35 |
# File 'lib/queries/concerns/notes.rb', line 31 def set_notes_params(params) @note_exact = params[:note_exact] @note_text = params[:note_text] @notes = boolean_param(params, :notes) end |