agilibox 1.2.0 → 1.2.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 +4 -4
- data/CHANGELOG.md +6 -0
- data/app/filters/agilibox/small_data/filter_strategy_by_date_or_datetime_period.rb +56 -0
- data/app/filters/agilibox/small_data/filter_strategy_by_date_period.rb +3 -35
- data/app/filters/agilibox/small_data/filter_strategy_by_datetime_period.rb +3 -35
- data/app/sorters/agilibox/sorter.rb +1 -1
- data/app/views/agilibox/_flash.html.slim +1 -1
- data/lib/agilibox/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b42ef5b03fc57fe2ff9cb01ac9aaf7b784b574eafe4ee68859501e088ff39e88
|
4
|
+
data.tar.gz: 782675f5041b1e5b41690217b995fdcc0b1ef225ad81d25489ca0f1e9a0db5ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 812c848c24e8e85dcf7da2b743fc7be4f2ea992fb5c77f2e352f5793e0a59b66127d07d4662f54563f879ad1061474e4e80bf6b6585ab8163f1f583cc44e699d
|
7
|
+
data.tar.gz: 83dfd77a0e25e0734e5294006a52def01817eb28c5fca6bddf36669454e0137cb29ff92321098890e5a95d3263dea9ac4829795a3c141ab03fecf53ad631296c
|
data/CHANGELOG.md
CHANGED
@@ -0,0 +1,56 @@
|
|
1
|
+
class Agilibox::SmallData::FilterStrategyByDateOrDatetimePeriod < ::Agilibox::SmallData::FilterStrategyByKeyValue
|
2
|
+
def initialize(*)
|
3
|
+
if self.class == Agilibox::SmallData::FilterStrategyByDateOrDatetimePeriod
|
4
|
+
raise "please use FilterStrategyByDatePeriod or FilterStrategyByDatetimePeriod"
|
5
|
+
end
|
6
|
+
|
7
|
+
super
|
8
|
+
end
|
9
|
+
|
10
|
+
def apply(query, value) # rubocop:disable Metrics/MethodLength
|
11
|
+
value = value.to_s
|
12
|
+
|
13
|
+
if value == "today"
|
14
|
+
a = now
|
15
|
+
b = now
|
16
|
+
elsif value == "yesterday"
|
17
|
+
a = (now - 1.day)
|
18
|
+
b = (now - 1.day)
|
19
|
+
elsif value == "this_week"
|
20
|
+
a = now.beginning_of_week
|
21
|
+
b = now.end_of_week
|
22
|
+
elsif value == "this_month"
|
23
|
+
a = now.beginning_of_month
|
24
|
+
b = now.end_of_month
|
25
|
+
elsif value == "this_year"
|
26
|
+
a = now.beginning_of_year
|
27
|
+
b = now.end_of_year
|
28
|
+
elsif value == "last_week"
|
29
|
+
a = (now - 1.week).beginning_of_week
|
30
|
+
b = (now - 1.week).end_of_week
|
31
|
+
elsif value == "last_month"
|
32
|
+
a = (now - 1.month).beginning_of_month
|
33
|
+
b = (now - 1.month).end_of_month
|
34
|
+
elsif value == "last_year"
|
35
|
+
a = (now - 1.year).beginning_of_year
|
36
|
+
b = (now - 1.year).end_of_year
|
37
|
+
elsif (m = value.match(/last\.([0-9]+)\.(days?|weeks?|months?|years?)/))
|
38
|
+
a = now - m[1].to_i.public_send(m[2])
|
39
|
+
b = now
|
40
|
+
else
|
41
|
+
return query
|
42
|
+
end
|
43
|
+
|
44
|
+
if now.is_a?(Time)
|
45
|
+
a = a.beginning_of_day if a
|
46
|
+
b = b.end_of_day if b
|
47
|
+
end
|
48
|
+
|
49
|
+
column = key.is_a?(Symbol) ? "#{query.model.table_name}.#{key}" : key.to_s
|
50
|
+
|
51
|
+
query = query.where("#{column} >= ?", a) if a
|
52
|
+
query = query.where("#{column} <= ?", b) if b
|
53
|
+
|
54
|
+
query
|
55
|
+
end
|
56
|
+
end
|
@@ -1,37 +1,5 @@
|
|
1
|
-
class Agilibox::SmallData::FilterStrategyByDatePeriod < ::Agilibox::SmallData::
|
2
|
-
def
|
3
|
-
|
4
|
-
|
5
|
-
if value == "today"
|
6
|
-
a = Date.current
|
7
|
-
b = Date.current
|
8
|
-
elsif value == "yesterday"
|
9
|
-
a = (Date.current - 1.day)
|
10
|
-
b = (Date.current - 1.day)
|
11
|
-
elsif value == "this_week"
|
12
|
-
a = Date.current.beginning_of_week
|
13
|
-
b = Date.current.end_of_week
|
14
|
-
elsif value == "this_month"
|
15
|
-
a = Date.current.beginning_of_month
|
16
|
-
b = Date.current.end_of_month
|
17
|
-
elsif value == "this_year"
|
18
|
-
a = Date.current.beginning_of_year
|
19
|
-
b = Date.current.end_of_year
|
20
|
-
elsif value == "last_week"
|
21
|
-
a = (Date.current - 1.week).beginning_of_week
|
22
|
-
b = (Date.current - 1.week).end_of_week
|
23
|
-
elsif value == "last_month"
|
24
|
-
a = (Date.current - 1.month).beginning_of_month
|
25
|
-
b = (Date.current - 1.month).end_of_month
|
26
|
-
elsif value == "last_year"
|
27
|
-
a = (Date.current - 1.year).beginning_of_year
|
28
|
-
b = (Date.current - 1.year).end_of_year
|
29
|
-
else
|
30
|
-
return query
|
31
|
-
end
|
32
|
-
|
33
|
-
column = key.is_a?(Symbol) ? "#{query.model.table_name}.#{key}" : key.to_s
|
34
|
-
|
35
|
-
query.where("#{column} >= ? AND #{column} <= ?", a, b)
|
1
|
+
class Agilibox::SmallData::FilterStrategyByDatePeriod < ::Agilibox::SmallData::FilterStrategyByDateOrDatetimePeriod
|
2
|
+
def now
|
3
|
+
Date.current
|
36
4
|
end
|
37
5
|
end
|
@@ -1,37 +1,5 @@
|
|
1
|
-
class Agilibox::SmallData::FilterStrategyByDatetimePeriod < ::Agilibox::SmallData::
|
2
|
-
def
|
3
|
-
|
4
|
-
|
5
|
-
if value == "today"
|
6
|
-
a = Time.zone.now.beginning_of_day
|
7
|
-
b = Time.zone.now.end_of_day
|
8
|
-
elsif value == "yesterday"
|
9
|
-
a = (Time.zone.now - 1.day).beginning_of_day
|
10
|
-
b = (Time.zone.now - 1.day).end_of_day
|
11
|
-
elsif value == "this_week"
|
12
|
-
a = Time.zone.now.beginning_of_week
|
13
|
-
b = Time.zone.now.end_of_week
|
14
|
-
elsif value == "this_month"
|
15
|
-
a = Time.zone.now.beginning_of_month
|
16
|
-
b = Time.zone.now.end_of_month
|
17
|
-
elsif value == "this_year"
|
18
|
-
a = Time.zone.now.beginning_of_year
|
19
|
-
b = Time.zone.now.end_of_year
|
20
|
-
elsif value == "last_week"
|
21
|
-
a = (Time.zone.now - 1.week).beginning_of_week
|
22
|
-
b = (Time.zone.now - 1.week).end_of_week
|
23
|
-
elsif value == "last_month"
|
24
|
-
a = (Time.zone.now - 1.month).beginning_of_month
|
25
|
-
b = (Time.zone.now - 1.month).end_of_month
|
26
|
-
elsif value == "last_year"
|
27
|
-
a = (Time.zone.now - 1.year).beginning_of_year
|
28
|
-
b = (Time.zone.now - 1.year).end_of_year
|
29
|
-
else
|
30
|
-
return query
|
31
|
-
end
|
32
|
-
|
33
|
-
column = key.is_a?(Symbol) ? "#{query.model.table_name}.#{key}" : key.to_s
|
34
|
-
|
35
|
-
query.where("#{column} >= ? AND #{column} <= ?", a, b)
|
1
|
+
class Agilibox::SmallData::FilterStrategyByDatetimePeriod < ::Agilibox::SmallData::FilterStrategyByDateOrDatetimePeriod
|
2
|
+
def now
|
3
|
+
Time.zone.now
|
36
4
|
end
|
37
5
|
end
|
@@ -3,7 +3,7 @@ class Agilibox::Sorter
|
|
3
3
|
|
4
4
|
attr_reader :collection, :sort_param, :column, :direction
|
5
5
|
|
6
|
-
def initialize(collection, sort_param)
|
6
|
+
def initialize(collection, sort_param = nil)
|
7
7
|
@collection = collection
|
8
8
|
@sort_param = sort_param
|
9
9
|
@column, @direction = sortable_column_order(sort_param.to_s)
|
data/lib/agilibox/version.rb
CHANGED
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.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- agilidée
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-05-
|
11
|
+
date: 2018-05-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails-i18n
|
@@ -87,6 +87,7 @@ files:
|
|
87
87
|
- app/filters/agilibox/small_data/filter_strategy_by_date.rb
|
88
88
|
- app/filters/agilibox/small_data/filter_strategy_by_date_begin.rb
|
89
89
|
- app/filters/agilibox/small_data/filter_strategy_by_date_end.rb
|
90
|
+
- app/filters/agilibox/small_data/filter_strategy_by_date_or_datetime_period.rb
|
90
91
|
- app/filters/agilibox/small_data/filter_strategy_by_date_period.rb
|
91
92
|
- app/filters/agilibox/small_data/filter_strategy_by_datetime_period.rb
|
92
93
|
- app/filters/agilibox/small_data/filter_strategy_by_key_value.rb
|