Class: Queries::TypeMaterialAutocompleteQuery

Inherits:
Query
  • Object
show all
Defined in:
lib/queries/type_material_autocomplete_query.rb

Instance Attribute Summary

Attributes inherited from Query

#dynamic_limit, #project_id, #query_string, #terms

Instance Method Summary (collapse)

Methods inherited from Query

#autocomplete, #build_terms, #cached, #combine_or_clauses, #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_id, #with_identifier, #with_identifier_like, #with_project_id, #years

Constructor Details

This class inherits a constructor from Queries::Query

Instance Method Details

- (Object) all



9
10
11
# File 'lib/queries/type_material_autocomplete_query.rb', line 9

def all
  TypeMaterial.includes(:protonym, material: [:identifiers] ).where(where_sql).references(:taxon_names).limit(dynamic_limit).all 
end

- (Object) identifier_table



21
22
23
# File 'lib/queries/type_material_autocomplete_query.rb', line 21

def identifier_table
  Identifier.arel_table
end

- (Object) table



13
14
15
# File 'lib/queries/type_material_autocomplete_query.rb', line 13

def table
  TypeMaterial.arel_table
end

- (Object) taxon_name_table



17
18
19
# File 'lib/queries/type_material_autocomplete_query.rb', line 17

def taxon_name_table
  TaxonName.arel_table
end

- (Object) where_sql



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

def where_sql
  with_project_id.and(with_cached_taxon_name.or(with_cached_identifier)).to_sql
end

- (Object) with_cached_identifier



30
31
32
# File 'lib/queries/type_material_autocomplete_query.rb', line 30

def with_cached_identifier
  identifier_table[:cached].matches_any(terms)
end

- (Object) with_cached_taxon_name

source, material, prototonym



26
27
28
# File 'lib/queries/type_material_autocomplete_query.rb', line 26

def with_cached_taxon_name
  taxon_name_table[:cached].matches_any(terms)
end