Class: Queries::Confidence::Filter

Inherits:
Query::Filter show all
Includes:
Concerns::Polymorphic
Defined in:
lib/queries/confidence/filter.rb

Constant Summary collapse

PARAMS =
[
  *::Confidence.related_foreign_keys.map(&:to_sym),
  :confidence_id,
  :confidence_level_id,
  :confidence_object_id,
  :confidence_object_type,
  confidence_id: [],
  confidence_level_id: [],
  confidence_object_type: [],
].freeze

Constants inherited from Query::Filter

Query::Filter::FILTER_QUERIES, Query::Filter::SUBQUERIES

Instance Attribute Summary collapse

Attributes inherited from Query::Filter

#api, #asserted_distribution_query, #biological_association_query, #biological_associations_graph_query, #collecting_event_query, #collection_object_query, #content_query, #controlled_vocabulary_term_query, #data_attribute_query, #depiction_query, #descriptor_query, #document_query, #dwc_occurrence_query, #extract_query, #field_occurrence_query, #image_query, #loan_query, #object_global_id, #observation_query, #order_by, #otu_query, #page, #paginate, #params, #per, #person_query, #project_id, #recent, #recent_target, #taxon_name_query, #venn, #venn_mode

Attributes inherited from Query

#query_string, #terms

Instance Method Summary collapse

Methods inherited from Query::Filter

#all, #all_and_clauses, #all_merge_clauses, #annotator_and_clauses, #annotator_merge_clauses, annotator_params, api_except_params, api_excluded_params, #apply_venn, #attribute_exact_facet, base_filter, base_query_name, base_query_to_h, #deep_permit, included_annotator_facets, instantiated_base_filter, inverted_subqueries, #merge_clauses, #model_id_facet, #object_global_id_facet, #only_project?, params, #permitted_params, #process_url_into_params, #project_id_facet, query_name, #query_name, #set_nested_queries, #shared_and_clauses, #subquery_vector, #target_and_clauses, #venn_query

Methods inherited from Query

#alphabetic_strings, #alphanumeric_strings, base_name, #base_name, #base_query, #build_terms, #cached_facet, #end_wildcard, #levenshtein_distance, #match_ordered_wildcard_pieces_in_cached, #no_terms?, referenced_klass, #referenced_klass, #referenced_klass_except, #referenced_klass_intersection, #referenced_klass_union, #start_and_end_wildcard, #start_wildcard, #table, #wildcard_pieces

Constructor Details

#initialize(query_params) ⇒ Filter

Returns a new instance of Filter.



31
32
33
34
35
36
37
38
39
# File 'lib/queries/confidence/filter.rb', line 31

def initialize(query_params)
  super
  @confidence_id = params[:confidence_id]
  @confidence_level_id = [params[:confidence_level_id]].flatten.compact
  @confidence_object_type = params[:confidence_object_type]
  @confidence_object_id = params[:confidence_object_id]

  set_polymorphic_params(params)
end

Instance Attribute Details

#confidence_idObject

Returns Array.

Returns:

  • Array



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

def confidence_id
  @confidence_id
end

#confidence_level_idObject

Returns Array.

Returns:

  • Array



22
23
24
# File 'lib/queries/confidence/filter.rb', line 22

def confidence_level_id
  @confidence_level_id
end

#confidence_object_idObject

Returns Array.

Returns:

  • Array



28
29
30
# File 'lib/queries/confidence/filter.rb', line 28

def confidence_object_id
  @confidence_object_id
end

#confidence_object_typeObject

Returns Array.

Returns:

  • Array



25
26
27
# File 'lib/queries/confidence/filter.rb', line 25

def confidence_object_type
  @confidence_object_type
end

Instance Method Details

#and_clausesObject



68
69
70
71
72
73
74
# File 'lib/queries/confidence/filter.rb', line 68

def and_clauses
  [
    confidence_level_id_facet,
    confidence_object_id_facet,
    confidence_object_type_facet,
  ]
end

#confidence_level_id_facetArel::Node?

Returns:

  • (Arel::Node, nil)


54
55
56
# File 'lib/queries/confidence/filter.rb', line 54

def confidence_level_id_facet
  confidence_level_id.present? ? table[:confidence_level_id].in(confidence_level_id)  : nil
end

#confidence_object_id_facetArel::Node?

Returns:

  • (Arel::Node, nil)


64
65
66
# File 'lib/queries/confidence/filter.rb', line 64

def confidence_object_id_facet
  confidence_object_id.empty? ? nil : table[:confidence_object_id].in(confidence_object_id)
end

#confidence_object_type_facetArel::Node?

Returns:

  • (Arel::Node, nil)


59
60
61
# File 'lib/queries/confidence/filter.rb', line 59

def confidence_object_type_facet
  confidence_object_type.present? ? table[:confidence_object_type].in(confidence_object_type)  : nil
end