Class: Queries::BiologicalCollectionObjectAutocompleteQuery

Inherits:
Query
  • Object
show all
Includes:
Arel::Nodes
Defined in:
lib/queries/biological_collection_object_autocomplete_query.rb

Instance Attribute Summary (collapse)

Attributes inherited from Query

#dynamic_limit, #project_id, #query_string

Instance Method Summary (collapse)

Methods inherited from Query

#build_terms, #cached, #end_wildcard, #exactly_named, #fragments, #initialize, #integers, #named, #no_digits, #only_ids, #only_integers?, #parent, #parent_child_join, #parent_child_where, #result, #scope, #start_and_end_wildcard, #start_wildcard, #strings, #wildcard_wrapped_integers, #with_identifier_like, #with_project_id, #years

Constructor Details

This class inherits a constructor from Queries::Query

Instance Attribute Details

- (Object) terms

Returns the value of attribute terms



5
6
7
# File 'lib/queries/biological_collection_object_autocomplete_query.rb', line 5

def terms
  @terms
end

Instance Method Details

- (Object) all



11
12
13
# File 'lib/queries/biological_collection_object_autocomplete_query.rb', line 11

def all 
  CollectionObject::BiologicalCollectionObject.includes(:identifiers, taxon_determinations: { otu:  :taxon_name }  ).where(where_sql).references(:taxon_names, :otus, :identifiers)
end

- (Object) identifier_table



23
24
25
# File 'lib/queries/biological_collection_object_autocomplete_query.rb', line 23

def identifier_table
  Identifier.arel_table
end

- (Object) otu_determined_as



39
40
41
# File 'lib/queries/biological_collection_object_autocomplete_query.rb', line 39

def otu_determined_as 
  otu_table[:name].matches_any(terms)
end

- (Object) otu_table



27
28
29
# File 'lib/queries/biological_collection_object_autocomplete_query.rb', line 27

def otu_table
  Otu.arel_table
end

- (Object) table



31
32
33
# File 'lib/queries/biological_collection_object_autocomplete_query.rb', line 31

def table
  CollectionObject.arel_table
end

- (Object) taxon_name_determination_table



19
20
21
# File 'lib/queries/biological_collection_object_autocomplete_query.rb', line 19

def taxon_name_determination_table
  TaxonNameDetermination.arel_table
end

- (Object) taxon_name_determined_as



43
44
45
# File 'lib/queries/biological_collection_object_autocomplete_query.rb', line 43

def taxon_name_determined_as 
  taxon_name_table[:name].matches_any(terms).or(taxon_name_table[:cached].matches_any(terms) )
end

- (Object) taxon_name_table



15
16
17
# File 'lib/queries/biological_collection_object_autocomplete_query.rb', line 15

def taxon_name_table
  TaxonName.arel_table
end

- (Object) where_sql



7
8
9
# File 'lib/queries/biological_collection_object_autocomplete_query.rb', line 7

def where_sql
  with_id.or(with_identifier_like).or(otu_determined_as).or(taxon_name_determined_as).to_sql
end

- (Object) with_id



35
36
37
# File 'lib/queries/biological_collection_object_autocomplete_query.rb', line 35

def with_id 
  table[:id].eq(terms.first.to_i)
end