Module: Card::Set::Abstract::Filter::QueryConstruction::Format

Extended by:
Card::Set::AbstractFormat
Defined in:
card/tmpsets/set/mod035-card-mod-search/abstract/03_filter/query_construction.rb,
card/tmpsets/set/mod036-card-mod-search/abstract/03_filter/query_construction.rb

Instance Method Summary collapse

Instance Method Details

#all_filter_keysObject

all filter keys in the order they were selected



10
11
12
# File 'card/tmpsets/set/mod035-card-mod-search/abstract/03_filter/query_construction.rb', line 10

def all_filter_keys
  @all_filter_keys ||= filter_keys_from_params | filter_keys
end

#blocked_id_cqlObject



33
34
35
36
# File 'card/tmpsets/set/mod035-card-mod-search/abstract/03_filter/query_construction.rb', line 33

def blocked_id_cql
  not_ids = filter_param :not_ids
  not_ids.present? ? { id: ["not in", not_ids.split(",")] } : {}
end

#current_sortObject



38
39
40
# File 'card/tmpsets/set/mod035-card-mod-search/abstract/03_filter/query_construction.rb', line 38

def current_sort
  sort_param || default_sort_option
end

#default_sort_optionObject



42
43
44
# File 'card/tmpsets/set/mod035-card-mod-search/abstract/03_filter/query_construction.rb', line 42

def default_sort_option
  card.cql_content[:sort]
end

#filter_and_sort_cqlObject



14
15
16
# File 'card/tmpsets/set/mod035-card-mod-search/abstract/03_filter/query_construction.rb', line 14

def filter_and_sort_cql
  filter_cql.merge sort_cql
end

#filter_cqlObject



18
19
20
21
22
# File 'card/tmpsets/set/mod035-card-mod-search/abstract/03_filter/query_construction.rb', line 18

def filter_cql
  return {} if filter_hash.empty?

  filter_cql_from_params
end

#filter_cql_from_paramsObject

separate method is needed for tests



25
26
27
# File 'card/tmpsets/set/mod035-card-mod-search/abstract/03_filter/query_construction.rb', line 25

def filter_cql_from_params
  filter_class.new(filter_keys_with_values, blocked_id_cql).to_cql
end

#sort_cqlObject



29
30
31
# File 'card/tmpsets/set/mod035-card-mod-search/abstract/03_filter/query_construction.rb', line 29

def sort_cql
  { sort: current_sort }
end