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, #options, #project_id, #query_string, #terms

Instance Method Summary (collapse)

Methods inherited from Query

#alphabetic_strings, #autocomplete, #autocomplete_cached, #autocomplete_cached_wildcard_anywhere, #autocomplete_identifier_cached_exact, #autocomplete_identifier_cached_like, #autocomplete_ordered_wildcard_pieces_in_cached, #autocomplete_start_date, #build_terms, #cached, #combine_or_clauses, #end_wildcard, #exactly_named, #fragments, #initialize, #integers, #match_ordered_wildcard_pieces_in_cached, #match_wildcard_cached, #named, #no_digits, #only_ids, #only_integers?, #parent, #parent_child_join, #parent_child_where, #pieces, #result, #scope, #simple_date, #start_and_end_wildcard, #start_wildcard, #wildcard_pieces, #wildcard_wrapped_integers, #wildcard_wrapped_years, #with_id, #with_identifier, #with_identifier_like, #with_project_id, #with_start_date, #year_letter, #years

Constructor Details

This class inherits a constructor from Queries::Query

Instance Method Details

- (Scope) all

Returns:

  • (Scope)


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

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

- (Arel::Table) identifier_table

Returns:

  • (Arel::Table)


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

def identifier_table
  ::Identifier.arel_table
end

- (Arel::Table) table

Returns:

  • (Arel::Table)


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

def table
  ::TypeMaterial.arel_table
end

- (Arel::Table) taxon_name_table

Returns:

  • (Arel::Table)


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

def taxon_name_table
  ::TaxonName.arel_table
end

- (String) where_sql

Returns:

  • (String)


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

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

- (Arel::Nodes::Matches) with_cached_identifier

Returns:

  • (Arel::Nodes::Matches)


37
38
39
# File 'lib/queries/type_material_autocomplete_query.rb', line 37

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

- (Arel::Nodes::Matches) with_cached_taxon_name

source, material, prototonym

Returns:

  • (Arel::Nodes::Matches)


32
33
34
# File 'lib/queries/type_material_autocomplete_query.rb', line 32

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