elasticated 2.5.0 → 2.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6637480a40d6c018f1edc45efa103df9c836f81f
4
- data.tar.gz: a65c27a00654dd7616e9f8086441f4365f616d24
3
+ metadata.gz: 7e134bcdf377161ed5a1909006e3c595a9e1a135
4
+ data.tar.gz: 0764431bff33cb0cf4b8ab04aaaee3641856bfce
5
5
  SHA512:
6
- metadata.gz: 1cda536b17d2dddb5d62be83cb2f2ae15555569df1fe7086574f1605c379897f12f9952e0047be486d4fc5b59f35f891544d7d466975b87ab4068a57b1b4b553
7
- data.tar.gz: 904e56da96d375422ac0951ffababf82f262e7afb68dd6a2cde125f1f9b2954bcc6d4eabb41bf4b3448132e352fcd451c462db4975cb597a5d9050acb07f396b
6
+ metadata.gz: affa393e491f7f3f89514a5485b2631cf573ecd09936b993328787f9ff5d4347c5ef9f2b87afc6203da63074de0e4038cd7be34d3f9f482df03c7329948286c1
7
+ data.tar.gz: 87a460bc7cef535d7c80a5071bdefd64de5ecd2101bb2fb6218cdc43ad4ab489b19625765374870183c4b37c9054036a79624b09f0c6f998a9593f9ee94a6441
@@ -40,13 +40,15 @@ module Elasticated
40
40
  private
41
41
 
42
42
  def extract_aggregation_delimiters(delimiters, field)
43
- delimiters.inject(delimiters.first) do |mcd_acum, delimiter|
43
+ first_delimiter = delimiters.first || {}
44
+ delimiters.inject(first_delimiter) do |mcd_acum, delimiter|
44
45
  merge_aggregation_repeated_keys(mcd_acum, delimiter, field)
45
46
  end
46
47
  end
47
48
 
48
49
  def extract_condition_delimiters(delimiters, field)
49
- delimiters.inject(delimiters.first) do |mcd_acum, delimiter|
50
+ first_delimiter = delimiters.first || {}
51
+ delimiters.inject(first_delimiter) do |mcd_acum, delimiter|
50
52
  merge_condition_repeated_keys(mcd_acum, delimiter, field)
51
53
  end
52
54
  end
data/lib/version.rb CHANGED
@@ -1,9 +1,12 @@
1
1
  module Elasticated
2
- VERSION = '2.5.0'
2
+ VERSION = '2.5.1'
3
3
  end
4
4
 
5
5
  # Changelog
6
6
 
7
+ # 2.5.1
8
+ # Se agregaron test para el merge delimiters en term delimiter factory que ahora considera arrays de delimiters vacios
9
+
7
10
  # 2.5.0
8
11
  # Ahora los delimiters son inmutables
9
12
  # Se puede delimitar por aggregations
@@ -72,9 +72,41 @@ module Elasticated
72
72
  expect(actual.build_strategy_params).to eq(expected.build_strategy_params)
73
73
  end
74
74
 
75
+ it 'should create term delimiter with two account from aggregation delimiter when delimiting by aggregations' do
76
+ options = {delimit_by: [:aggregations]}
77
+ query_delimiters = { conditions: [], aggregations: [{account: [39]}, {account: [40]}] }
78
+ expected = Elasticated::Delimiters::TermFieldDelimiter.new(field: :account, as: :accounts, values: [39,40])
79
+ actual = Elasticated.term_delimiter_factory.create(empty_delimiter, query_delimiters, options)
80
+ expect(actual.build_strategy_params).to eq(expected.build_strategy_params)
81
+ end
82
+
83
+ it 'should create term delimiter with no accounts from aggregation delimiter when there are at least one condition delimiters' do
84
+ options = {delimit_by: [:conditions, :aggregations]}
85
+ query_delimiters = { conditions: [{account: [31]}], aggregations: [{account: [39]}, {account: [40]}] }
86
+ expected = Elasticated::Delimiters::TermFieldDelimiter.new(field: :account, as: :accounts, values: [31])
87
+ actual = Elasticated.term_delimiter_factory.create(empty_delimiter, query_delimiters, options)
88
+ expect(actual.build_strategy_params).to eq(expected.build_strategy_params)
89
+ end
90
+
91
+ it 'should create term delimiter with two accounts from aggregation delimiter when there are no condition delimiters' do
92
+ options = {delimit_by: [:conditions, :aggregations]}
93
+ query_delimiters = { conditions: [], aggregations: [{account: [39]}, {account: [40]}] }
94
+ expected = Elasticated::Delimiters::TermFieldDelimiter.new(field: :account, as: :accounts, values: [39,40])
95
+ actual = Elasticated.term_delimiter_factory.create(empty_delimiter, query_delimiters, options)
96
+ expect(actual.build_strategy_params).to eq(expected.build_strategy_params)
97
+ end
98
+
99
+ it 'should create term delimiter with two accounts from condition delimiters when there are not aggregation delimiters' do
100
+ options = {delimit_by: [:conditions, :aggregations]}
101
+ query_delimiters = { conditions: [{account: [39]}, {account: [40]}], aggregations: [] }
102
+ expected = Elasticated::Delimiters::TermFieldDelimiter.new(field: :account, as: :accounts, values: [39,40])
103
+ actual = Elasticated.term_delimiter_factory.create(empty_delimiter, query_delimiters, options)
104
+ expect(actual.build_strategy_params).to eq(expected.build_strategy_params)
105
+ end
106
+
75
107
  it 'should merge empty delimiters' do
76
- condition_delimiters = [{}]
77
- aggregation_delimiters = [{}]
108
+ condition_delimiters = []
109
+ aggregation_delimiters = []
78
110
  field = :account
79
111
  expected = {}
80
112
  actual = Elasticated.term_delimiter_factory.merge_delimiters(condition_delimiters, aggregation_delimiters, field)
@@ -82,7 +114,7 @@ module Elasticated
82
114
  end
83
115
 
84
116
  it 'should merge empty condition delimiter with one aggregation delimiter' do
85
- condition_delimiters = [{}]
117
+ condition_delimiters = []
86
118
  aggregation_delimiters = [{account: [39]}]
87
119
  field = :account
88
120
  expected = {account: [39]}
@@ -91,7 +123,7 @@ module Elasticated
91
123
  end
92
124
 
93
125
  it 'should merge empty condition delimiter with two aggregation delimiters' do
94
- condition_delimiters = [{}]
126
+ condition_delimiters = []
95
127
  aggregation_delimiters = [{account: [39]}, {account: [40]}]
96
128
  field = :account
97
129
  expected = {account: [39, 40]}
@@ -100,7 +132,7 @@ module Elasticated
100
132
  end
101
133
 
102
134
  it 'should merge empty condition delimiter with two different aggregation delimiters' do
103
- condition_delimiters = [{}]
135
+ condition_delimiters = []
104
136
  aggregation_delimiters = [{account: [39]}, {tags: ["a_tag"]}]
105
137
  field = :account
106
138
  expected = {}
@@ -362,5 +394,6 @@ module Elasticated
362
394
  actual = Elasticated.date_delimiter_factory.create(empty_delimiter, query_delimiters, options)
363
395
  expect(actual.build_strategy_params).to eq(expected.build_strategy_params)
364
396
  end
397
+
365
398
  end
366
399
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elasticated
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.0
4
+ version: 2.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pablo Fernandez