elasticated 2.2.0 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/elasticated/aggregations/date_histogram_aggregation.rb +1 -6
- data/lib/elasticated/aggregations/safe_date_histogram_aggregation.rb +1 -6
- data/lib/elasticated/delimiters/date_field_delimiter.rb +6 -2
- data/lib/version.rb +3 -1
- data/spec/aggregation_spec.rb +6 -0
- data/spec/date_field_delimiter_spec.rb +6 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a8153fc5ed863fc035edd819e032298c140942d
|
4
|
+
data.tar.gz: b92fbd97b92746e57982ae8d053214242986b239
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3455584f5b597ec4c21df45378ee2f23f0694f6129bb40d0b3392bfba3e8efeeb4582f30ee636fc716bc2a72ede184b0b37e40af8665c3f78890279f00387b53
|
7
|
+
data.tar.gz: eccb09df3c2ab43a38e795c7d063b4a36551652053f821be0304dfc3c60e5456e18b00f7d2a0e15986f8192c53e574e9876049d9fb309aa0f0299ae2db156e07
|
@@ -2,21 +2,16 @@ module Elasticated
|
|
2
2
|
class DateHistogramAggregation < HistogramAggregation
|
3
3
|
include Subaggregated
|
4
4
|
|
5
|
-
attr_accessor :format
|
5
|
+
attr_accessor :format
|
6
6
|
|
7
7
|
def initialize(field, opts={}, &block)
|
8
8
|
self.format = opts.delete(:format) || 'yyyy-MM-dd'
|
9
9
|
interval = opts.delete(:interval) || 'day'
|
10
|
-
self.offset = opts.delete(:offset)
|
11
10
|
super field, interval, opts, &block
|
12
11
|
end
|
13
12
|
|
14
13
|
def build
|
15
14
|
terms = { field: field, interval: interval, format: format }
|
16
|
-
if offset # '1.4 style'
|
17
|
-
terms.merge! pre_offset: offset
|
18
|
-
terms.merge! post_offset: offset
|
19
|
-
end
|
20
15
|
terms.merge! extra_params
|
21
16
|
aggregation_struct = { date_histogram: terms }
|
22
17
|
aggregation_struct.merge! build_subaggregations
|
@@ -4,10 +4,9 @@ module Elasticated
|
|
4
4
|
|
5
5
|
DEFAULT_INTERVAL = '1d'
|
6
6
|
|
7
|
-
attr_accessor :
|
7
|
+
attr_accessor :time_zone, :points, :compact, :include_count
|
8
8
|
|
9
9
|
def initialize(field, opts={}, &block)
|
10
|
-
self.offset = opts.delete(:offset)
|
11
10
|
self.time_zone = opts.delete(:time_zone)
|
12
11
|
self.points = opts.fetch(:points)
|
13
12
|
opts.delete(:points)
|
@@ -19,10 +18,6 @@ module Elasticated
|
|
19
18
|
|
20
19
|
def build
|
21
20
|
terms = { field: field, interval: safe_interval.to_s }
|
22
|
-
if offset # '1.4 style'
|
23
|
-
terms.merge! pre_offset: offset
|
24
|
-
terms.merge! post_offset: offset
|
25
|
-
end
|
26
21
|
if time_zone
|
27
22
|
terms.merge! time_zone: time_zone
|
28
23
|
end
|
@@ -22,8 +22,12 @@ module Elasticated
|
|
22
22
|
params.merge! date_since: date_since if date_since
|
23
23
|
params.merge! date_until: date_until if date_until
|
24
24
|
else
|
25
|
-
|
26
|
-
|
25
|
+
if values.count > 1
|
26
|
+
params.merge! date_since: values.min
|
27
|
+
params.merge! date_until: values.max
|
28
|
+
else
|
29
|
+
params.merge! date: values.first
|
30
|
+
end
|
27
31
|
end
|
28
32
|
params
|
29
33
|
end
|
data/lib/version.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
module Elasticated
|
2
|
-
VERSION = '2.
|
2
|
+
VERSION = '2.3.0'
|
3
3
|
end
|
4
4
|
|
5
5
|
# Changelog
|
6
6
|
|
7
|
+
# Ahora DateFieldDelimiter admite multiples fechas declaradas en un TermsCondition
|
8
|
+
|
7
9
|
# 2.2.0
|
8
10
|
# Se agrega la funcionalidad para especificar un orden aleatorio en las queries
|
9
11
|
|
data/spec/aggregation_spec.rb
CHANGED
@@ -251,6 +251,12 @@ module Elasticated
|
|
251
251
|
expect(agg.build).to eq expected_result
|
252
252
|
end
|
253
253
|
|
254
|
+
it "should build a date histogram aggregation with offset for date" do
|
255
|
+
agg = DateHistogramAggregation.new :date, offset: '+6h'
|
256
|
+
expected_result = { date_histogram: { field: :date, interval: 'day', format: 'yyyy-MM-dd', offset: '+6h' } }
|
257
|
+
expect(agg.build).to eq expected_result
|
258
|
+
end
|
259
|
+
|
254
260
|
it "should build a date histogram aggregation with subaggregations" do
|
255
261
|
agg = DateHistogramAggregation.new :date do |docs|
|
256
262
|
docs.max :numeric_field
|
@@ -19,10 +19,12 @@ module Elasticated
|
|
19
19
|
expect(params).to eq date: '2016-07-19'
|
20
20
|
end
|
21
21
|
|
22
|
-
it "should
|
23
|
-
delimiter.add_term :created_at, '
|
24
|
-
delimiter.add_term :created_at, '
|
25
|
-
|
22
|
+
it "should delimit by multiple terms" do
|
23
|
+
delimiter.add_term :created_at, '2017-03-30'
|
24
|
+
delimiter.add_term :created_at, '2017-03-25'
|
25
|
+
delimiter.add_term :created_at, '2017-03-27'
|
26
|
+
params = delimiter.build_strategy_params
|
27
|
+
expect(params).to eq date_since: '2017-03-25', date_until: '2017-03-30'
|
26
28
|
end
|
27
29
|
|
28
30
|
it "should delimit by a min date" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elasticated
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pablo Fernandez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-03-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|