elasticsearch_record 1.7.0 → 1.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 52f19a4a5802d333a04d2c72e4a7a51c3f0bfc501c0b8b379e6afb44d1076aca
|
4
|
+
data.tar.gz: ac2eb76b596b4705feac42612fb0e11d530f684750ee780471c765172a69ea7f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 68b0cc2c384b7751c271aa1d3f8b37af778d20af1ca6e42a967b97454ab2121a0606150977690a9153b58567d2172c5e08cfe2adbf7578e3051c60edf0c4a1a4
|
7
|
+
data.tar.gz: bf240b8ccd09364d6237900854c824080068cd6822400f7538dabedd85491cb64dbe45b86725aa353fe9fc598e4e2d4837935775e132af11215ea767daf2b7e1
|
data/docs/CHANGELOG.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
# ElasticsearchRecord - CHANGELOG
|
2
2
|
|
3
|
+
## [1.7.1] - 2024-01-09
|
4
|
+
* [fix] `ElasticsearchRecord::Relation` calculation methods return with different nodes
|
5
|
+
* [ref] `ElasticsearchRecord::Relation#calculate` removes default value of `node`
|
6
|
+
* [ref] `ActiveRecord::ConnectionAdapters::ElasticsearchAdapter#api` prevents inaccurate variable interpretation of `log`
|
7
|
+
|
3
8
|
## [1.7.0] - 2024-01-09
|
4
9
|
* [add] `ElasticsearchRecord::Relation#boxplot` calculation method
|
5
10
|
* [add] `ElasticsearchRecord::Relation#stats` calculation method
|
@@ -238,7 +238,7 @@ module ActiveRecord # :nodoc:
|
|
238
238
|
# resolve the API target
|
239
239
|
target = namespace == :core ? @connection : @connection.__send__(namespace)
|
240
240
|
|
241
|
-
log
|
241
|
+
__send__(:log, "#{namespace}.#{action}", arguments, name, async: async, log: log) do
|
242
242
|
response = ActiveSupport::Dependencies.interlock.permit_concurrent_loads do
|
243
243
|
target.__send__(action, arguments)
|
244
244
|
end
|
@@ -168,7 +168,7 @@ module ElasticsearchRecord
|
|
168
168
|
# @param [Symbol, String] column_name
|
169
169
|
# @param [Array] values
|
170
170
|
def percentile_ranks(column_name, values)
|
171
|
-
calculate(:
|
171
|
+
calculate(:percentile_ranks, column_name, opts: { values: values }, node: :values)
|
172
172
|
end
|
173
173
|
|
174
174
|
# Calculates the cardinality on a given column. Returns +0+ if there's no row.
|
@@ -180,7 +180,7 @@ module ElasticsearchRecord
|
|
180
180
|
#
|
181
181
|
# @param [Symbol, String] column_name
|
182
182
|
def cardinality(column_name)
|
183
|
-
calculate(:cardinality, column_name)
|
183
|
+
calculate(:cardinality, column_name, node: :value)
|
184
184
|
end
|
185
185
|
|
186
186
|
# Calculates the average value on a given column. Returns +nil+ if there's no row. See #calculate for examples with options.
|
@@ -191,7 +191,7 @@ module ElasticsearchRecord
|
|
191
191
|
#
|
192
192
|
# @param [Symbol, String] column_name
|
193
193
|
def average(column_name)
|
194
|
-
calculate(:avg, column_name)
|
194
|
+
calculate(:avg, column_name, node: :value)
|
195
195
|
end
|
196
196
|
|
197
197
|
# Calculates the minimum value on a given column. The value is returned
|
@@ -204,7 +204,7 @@ module ElasticsearchRecord
|
|
204
204
|
#
|
205
205
|
# @param [Symbol, String] column_name
|
206
206
|
def minimum(column_name)
|
207
|
-
calculate(:min, column_name)
|
207
|
+
calculate(:min, column_name, node: :value)
|
208
208
|
end
|
209
209
|
|
210
210
|
# Calculates the maximum value on a given column. The value is returned
|
@@ -217,7 +217,7 @@ module ElasticsearchRecord
|
|
217
217
|
#
|
218
218
|
# @param [Symbol, String] column_name
|
219
219
|
def maximum(column_name)
|
220
|
-
calculate(:max, column_name)
|
220
|
+
calculate(:max, column_name, node: :value)
|
221
221
|
end
|
222
222
|
|
223
223
|
# This single-value aggregation approximates the median absolute deviation of its search results.
|
@@ -247,7 +247,7 @@ module ElasticsearchRecord
|
|
247
247
|
#
|
248
248
|
# @param [Symbol, String] column_name (optional)
|
249
249
|
def sum(column_name)
|
250
|
-
calculate(:sum, column_name)
|
250
|
+
calculate(:sum, column_name, node: :value)
|
251
251
|
end
|
252
252
|
|
253
253
|
# creates a aggregation with the provided metric (e.g. :sum) and columns.
|
@@ -255,8 +255,8 @@ module ElasticsearchRecord
|
|
255
255
|
# @param [Symbol, String] metric
|
256
256
|
# @param [Array<Symbol|String>] columns
|
257
257
|
# @param [Hash] opts - additional arguments that get merged with the metric definition
|
258
|
-
# @param [Symbol] node (default
|
259
|
-
def calculate(metric, *columns, opts: {}, node:
|
258
|
+
# @param [Symbol] node (default: nil)
|
259
|
+
def calculate(metric, *columns, opts: {}, node: nil)
|
260
260
|
metric_key = "calculate_#{metric}"
|
261
261
|
|
262
262
|
# spawn a new aggregation and return the aggs
|
@@ -266,7 +266,11 @@ module ElasticsearchRecord
|
|
266
266
|
aggregate(metric_key, { metric => { fields: columns }.merge(opts) }).aggregations
|
267
267
|
end
|
268
268
|
|
269
|
-
|
269
|
+
if node.present?
|
270
|
+
response[metric_key][node]
|
271
|
+
else
|
272
|
+
response[metric_key]
|
273
|
+
end
|
270
274
|
end
|
271
275
|
end
|
272
276
|
end
|