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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7387656ed02b23a0dd1926af85e5bc0f1d6e11fe
4
- data.tar.gz: 238aa946faf6a8c8472df905e5239ce01b42dffe
3
+ metadata.gz: 0a8153fc5ed863fc035edd819e032298c140942d
4
+ data.tar.gz: b92fbd97b92746e57982ae8d053214242986b239
5
5
  SHA512:
6
- metadata.gz: 28c779821945de5bfc766e516b85e7e691c9bc41eb2a8dcb48028fd7a695add6ccc63e20b33358ce68ae3470ddca97c26bfd6cd224fb4ebdca9471d309224c89
7
- data.tar.gz: e19fbc522bb1e6d1f4227051a8a9f72232baede359213f5fd94375a561ba8cec5e9439d66e47b5368c25e7a6092fe105ae9d2a6a6bb367b175a9f4908655a40e
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, :offset
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 :offset, :time_zone, :points, :compact, :include_count
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
- raise "Only one 'term' filter is allowed over the '#{field_name}' field" if values.count > 1
26
- params.merge! date: values.first
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
@@ -1,9 +1,11 @@
1
1
  module Elasticated
2
- VERSION = '2.2.0'
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
 
@@ -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 raise when delimit by multiple terms" do
23
- delimiter.add_term :created_at, 'nombre1'
24
- delimiter.add_term :created_at, 'nombre2'
25
- expect{ delimiter.build_strategy_params }.to raise_error
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.2.0
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-01-19 00:00:00.000000000 Z
11
+ date: 2017-03-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler