agilibox 1.5.5 → 1.5.6

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: 3d0a7833192d2c2cdd413fcd91fbeea277099a5eed266af261f42c3b64584b65
4
- data.tar.gz: be55f55b5c5bc7a7158db2a35742e946b823df0d1080d7f88572cf445d45a9b5
3
+ metadata.gz: b89a1c4a5176d64607c6df1c179a5519858b7c7469bbbefd0d6c128ad1372e5c
4
+ data.tar.gz: 31e6c78eafb56b047a8c5af9df93067c3fbbd61958134e9fe36b22d56cdcf1fd
5
5
  SHA512:
6
- metadata.gz: 9c7162d24df15b7c2e64ab4c15426c17f0ef39f8fc87ec9a41faa90febcd96b105cecc13662cbaf720b320b59a685897dc7d45555c650bd9034645151b3607c5
7
- data.tar.gz: af43c646d359fefa89e3d9cd9212fe61e6cc33ed555a133150ffa138551347944fd1fdb4ef1bb255eda1b35d95c507f10822b1900bb0f4fee6a37c50823f7d72
6
+ metadata.gz: 1c01d71e66266e67e467c2359be424c6407136d15dd8fcf4eddfce790f10242d9dcb33c39e69192c8e55d87d85a58d21008ac830df418306ddd0be2eb555fa8b
7
+ data.tar.gz: c469f7c350ec36085b4976c728bac1713a567b163ae682b670282f4e38924c4cf7704a188151635534c4b76c3dbdc997c46b208116d18144f5c71177845d6da5
data/CHANGELOG.md CHANGED
@@ -2,6 +2,9 @@
2
2
 
3
3
  ## Next version
4
4
 
5
+ ## 1.5.6
6
+ - Various fixes on filters
7
+
5
8
  ## 1.5.5
6
9
  - Add ModelI18n::raise_on_missing_translations option
7
10
 
@@ -1,6 +1,7 @@
1
1
  class Agilibox::SmallData::FilterStrategyByDateBegin < ::Agilibox::SmallData::FilterStrategyByKeyValue
2
2
  def apply(query, value)
3
3
  value = Time.zone.parse(value).beginning_of_day
4
- query.where("#{key} >= ?", value)
4
+ column = column_for(query)
5
+ query.where("#{column} >= ?", value)
5
6
  end
6
7
  end
@@ -1,6 +1,7 @@
1
1
  class Agilibox::SmallData::FilterStrategyByDateEnd < ::Agilibox::SmallData::FilterStrategyByKeyValue
2
2
  def apply(query, value)
3
3
  value = Time.zone.parse(value).end_of_day
4
- query.where("#{key} <= ?", value)
4
+ column = column_for(query)
5
+ query.where("#{column} <= ?", value)
5
6
  end
6
7
  end
@@ -46,7 +46,7 @@ class Agilibox::SmallData::FilterStrategyByDateOrDatetimePeriod < ::Agilibox::Sm
46
46
  b = b.end_of_day if b
47
47
  end
48
48
 
49
- column = key.is_a?(Symbol) ? "#{query.model.table_name}.#{key}" : key.to_s
49
+ column = column_for(query)
50
50
 
51
51
  query = query.where("#{column} >= ?", a) if a
52
52
  query = query.where("#{column} <= ?", b) if b
@@ -8,9 +8,19 @@ class Agilibox::SmallData::FilterStrategyByKeyValue < ::Agilibox::SmallData::Fil
8
8
  def apply(query, value)
9
9
  value = true if value == "true"
10
10
  value = false if value == "false"
11
- value = nil if value == "nil"
12
- value = nil if value == "null"
13
11
 
14
- query.where("#{key} = ?", value)
12
+ column = column_for(query)
13
+
14
+ if value.to_s.in?(%w(nil null))
15
+ query.where("#{column} IS NULL")
16
+ elsif value.to_s.in?(%w(not_nil not_null))
17
+ query.where("#{column} IS NOT NULL")
18
+ else
19
+ query.where("#{column} = ?", value)
20
+ end
21
+ end
22
+
23
+ def column_for(query)
24
+ key.is_a?(Symbol) ? "#{query.model.table_name}.#{key}" : key.to_s
15
25
  end
16
26
  end
@@ -1,16 +1,11 @@
1
- class Agilibox::SmallData::FilterStrategyByKeyValues < ::Agilibox::SmallData::FilterStrategy
2
- attr_reader :key
3
-
4
- def initialize(key = nil)
5
- @key = key
6
- end
7
-
1
+ class Agilibox::SmallData::FilterStrategyByKeyValues < ::Agilibox::SmallData::FilterStrategyByKeyValue
8
2
  def apply(query, value)
9
3
  value = value.split(" ") if value.is_a?(String)
10
4
  value = value.select(&:present?)
5
+ column = column_for(query)
11
6
 
12
7
  if value.any?
13
- query.where("#{key} IN (?)", value)
8
+ query.where("#{column} IN (?)", value)
14
9
  else
15
10
  query
16
11
  end
@@ -1,3 +1,3 @@
1
1
  module Agilibox
2
- VERSION = "1.5.5"
2
+ VERSION = "1.5.6"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: agilibox
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.5
4
+ version: 1.5.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - agilidée
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-19 00:00:00.000000000 Z
11
+ date: 2019-02-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails-i18n