active_reporter 0.7.2 → 0.7.3

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: cdb5fb124ebcc7d60f4f7e51b3c832a7a9be93b3a9a4e456e7695ddb16e2a336
4
- data.tar.gz: '08a7417b448df20464dea0cf66b2dfa83082eaf54c1eb5c423d0ef973eaebacf'
3
+ metadata.gz: bd621943a7508651f94f389d81cb897e5dc7eae2d10f9dd2f261f29533bdc588
4
+ data.tar.gz: da5082a988b18ff4f821f4e96c184f0e0bfae72bcc0474de2b6d110481bd428b
5
5
  SHA512:
6
- metadata.gz: 55f35f09f458c58c3429da7dc77756705fb79511651f62cb0c1b87726ccbd8629c4468ea9b5b7922831dde530f90c925abee0d4f1e306a2f0ed927ddb982e4f1
7
- data.tar.gz: 19b800d38de1b9beb846fcdf2f0516a2281fce10898df5cfc4ea424c986aa06cb5ee8736b5897240adc959216362218ef72503ee6bbb0613f4c634c48743b60e
6
+ metadata.gz: 561cc794d2820d10b6f62abb3a0da32f86a0dad34e007c6e5dede83ef30f5d6433cea1d308e44561a24fa3a30360859ccd7b9efb87a47078d9afc541654f40ef
7
+ data.tar.gz: d64d12a3fc5df2f0af7505f49f1987b963a2d7ed3909128e5af5cc7b42acf9c8e9c0d084924d9ae7cbe4c6941eafabf79730d054fe3722190d7c190bcc7e309e
@@ -116,7 +116,7 @@ module ActiveReporter
116
116
  def autopopulate_bins
117
117
  return [] if bin_start.blank? || bin_end.blank?
118
118
 
119
- bin_count = [((bin_end - bin_start)/(bin_width)).to_i, 1].max
119
+ bin_count = ((bin_end - bin_start)/(bin_width)).to_i
120
120
  invalid_param!(:bin_width, "is too small for the domain; would generate #{bin_count.to_i} bins") if bin_count > max_bins
121
121
 
122
122
  bins = bin_count.times.map { |i| { min: (bin_start + (bin_width*i)), max: (bin_start + (bin_width*i.next)) } }
@@ -13,6 +13,22 @@ module ActiveReporter
13
13
  enum_values.keys.tap { |values| values.unshift(nil) unless values.include?(nil) }.uniq
14
14
  end
15
15
 
16
+ def filter(relation)
17
+ values = if Rails.gem_version >= Gem::Version.new("7")
18
+ filter_values.map { |value| enum_values[value] }.uniq
19
+ else
20
+ filter_values
21
+ end
22
+ query = case values
23
+ when [] then "1=0"
24
+ when [nil] then "#{expression} IS NULL"
25
+ else
26
+ in_values = "#{expression} IN (?)"
27
+ values.include?(nil) ? "#{expression} IS NULL OR #{in_values}" : in_values
28
+ end
29
+ relation.where(query, values.compact)
30
+ end
31
+
16
32
  private
17
33
 
18
34
  def enum_values
@@ -31,7 +47,7 @@ module ActiveReporter
31
47
  end
32
48
 
33
49
  def enum?
34
- true # Hash(model&.defined_enums).include?(attribute.to_s)
50
+ Hash(model&.defined_enums).include?(attribute.to_s)
35
51
  end
36
52
  end
37
53
  end
@@ -1,3 +1,3 @@
1
1
  module ActiveReporter
2
- VERSION = "0.7.2"
2
+ VERSION = "0.7.3"
3
3
  end