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 +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/active_median/model.rb +2 -2
- data/lib/active_median/mongoid.rb +1 -0
- data/lib/active_median/sqlite_handler.rb +1 -0
- data/lib/active_median/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8fac5b8a4669bedd7b9a7bd104c375df5acf6c9e60bc2c91ec97efb2ebea6969
|
4
|
+
data.tar.gz: afc2609d7983f06b975244e57ab4f6890916fdc3943870974a56d50cca19a832
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3cff2041e5d602bd84f99f99cd75efbe6fba5c78faf4efbd6b3886edb91bf1db7deeca609ded57a859f10e670298f04a225f3f1b69ea8b4df9aecda68661b5e
|
7
|
+
data.tar.gz: d494fddff7e01063c99d549d4669f6efff207fef25f71761329d3c16166bc6a268f02020e12adde251be855ed0c31998f47fb73890689565bb67a0c320875b06
|
data/CHANGELOG.md
CHANGED
data/lib/active_median/model.rb
CHANGED
@@ -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(:@
|
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(:@
|
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}")
|
@@ -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
|