Class: Queries::GeographicAreaAutocompleteQuery

Inherits:
Query
  • Object
show all
Includes:
Arel::Nodes
Defined in:
lib/queries/geographic_area_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

#build_terms, #end_wildcard, #fragments, #identifier_table, #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_like, #with_project_id, #years

Constructor Details

This class inherits a constructor from Queries::Query

Instance Method Details

- (Object) all



12
13
14
15
16
17
18
# File 'lib/queries/geographic_area_autocomplete_query.rb', line 12

def all 
  (
    GeographicArea.where(name: query_string).all +  
    GeographicArea.joins(parent_child_join).where(parent_child_where.to_sql).limit(5).all +
    GeographicArea.where(where_sql).includes(:geographic_area_type, :geographic_items).order('length(name)').limit(dynamic_limit).all
  ).flatten.compact.uniq
end

- (Object) table



20
21
22
# File 'lib/queries/geographic_area_autocomplete_query.rb', line 20

def table
  GeographicArea.arel_table
end

- (Object) where_sql

TODO: use or_clauses



8
9
10
# File 'lib/queries/geographic_area_autocomplete_query.rb', line 8

def where_sql
  named.to_sql
end