active_median 0.3.2 → 0.3.3

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
  SHA256:
3
- metadata.gz: 7589b66aa9d74af6afe94a766603a36feadf9b0f36d7be01212e97a4ae1de423
4
- data.tar.gz: de6fa949edc2220610f97ff42a03ce7f50cc1cf9e66979846c570c3a13e3e6b8
3
+ metadata.gz: 8fac5b8a4669bedd7b9a7bd104c375df5acf6c9e60bc2c91ec97efb2ebea6969
4
+ data.tar.gz: afc2609d7983f06b975244e57ab4f6890916fdc3943870974a56d50cca19a832
5
5
  SHA512:
6
- metadata.gz: d2739f3b083658090a61b283d5d416f61e4b998576fe8a704cbcb22a7c2fb621f8b1c89c422bae8cf67cf3784624d5f056837980c2fa80737df67edbc337490c
7
- data.tar.gz: 9bac410d399bf81668e999d28da3f804ad4ab7e8891db726bbb07980a201902ca107d866b0f27866170df41c97c63d72cf4be4768666f67197f593d559da88b7
6
+ metadata.gz: f3cff2041e5d602bd84f99f99cd75efbe6fba5c78faf4efbd6b3886edb91bf1db7deeca609ded57a859f10e670298f04a225f3f1b69ea8b4df9aecda68661b5e
7
+ data.tar.gz: d494fddff7e01063c99d549d4669f6efff207fef25f71761329d3c16166bc6a268f02020e12adde251be855ed0c31998f47fb73890689565bb67a0c320875b06
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.3.3 (2021-08-17)
2
+
3
+ - Fixed null values for SQLite without an extension and MongoDB
4
+
1
5
  ## 0.3.2 (2021-08-16)
2
6
 
3
7
  - Added support for SQLite without an extension
@@ -67,12 +67,12 @@ module ActiveMedian
67
67
  relation.select(*group_values, "PERCENTILE_CONT(#{percentile}) WITHIN GROUP (ORDER BY #{column}) OVER (#{over}) AS #{column_alias}").unscope(:group)
68
68
  when /sqlite/i
69
69
  db = connection.raw_connection
70
- unless db.instance_variable_get(:@active_median_handler)
70
+ unless db.instance_variable_get(:@active_median)
71
71
  if db.get_first_value("SELECT 1 FROM pragma_function_list WHERE name = 'percentile'").nil?
72
72
  require "active_median/sqlite_handler"
73
73
  db.create_aggregate_handler(ActiveMedian::SQLiteHandler)
74
74
  end
75
- db.instance_variable_set(:@active_median_handler, true)
75
+ db.instance_variable_set(:@active_median, true)
76
76
  end
77
77
 
78
78
  relation.select(*group_values, "PERCENTILE(#{column}, #{percentile} * 100) AS #{column_alias}")
@@ -11,6 +11,7 @@ module ActiveMedian
11
11
 
12
12
  relation =
13
13
  all
14
+ .where(column => {"$ne" => nil})
14
15
  .asc(column)
15
16
  .group(_id: nil, values: {"$push" => "$#{column}"}, count: {"$sum" => 1})
16
17
  .project(values: 1, count: {"$subtract" => ["$count", 1]})
@@ -18,6 +18,7 @@ module ActiveMedian
18
18
  # 2. percentile same for all rows
19
19
  # since input is already checked
20
20
  def step(ctx, value, percentile)
21
+ return if value.nil?
21
22
  raise ActiveRecord::StatementInvalid, "1st argument to percentile() is not numeric" unless value.is_a?(Numeric)
22
23
  @percentile ||= percentile
23
24
  @values << value
@@ -1,3 +1,3 @@
1
1
  module ActiveMedian
2
- VERSION = "0.3.2"
2
+ VERSION = "0.3.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_median
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane