mongoid_occurrences 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -2
- data/CHANGELOG.md +5 -0
- data/lib/mongoid_occurrences/occurrence/has_daily_occurrences.rb +12 -19
- data/lib/mongoid_occurrences/occurrence/has_schedule.rb +1 -1
- data/lib/mongoid_occurrences/occurrence.rb +12 -0
- data/lib/mongoid_occurrences/queries/occurs_between.rb +2 -2
- data/lib/mongoid_occurrences/queries/occurs_on.rb +1 -1
- data/lib/mongoid_occurrences/queries/occurs_until.rb +1 -1
- data/lib/mongoid_occurrences/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 475b41580d7ffc83d7c4d794425a52f53a6e56e31d0a979f18d44f99339a1904
|
4
|
+
data.tar.gz: 869e8ff6af04f48fa176cefc0753833b320f225d937e956449820c8f1e2a3206
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a80de303c833964bd19546d4f76fd818e0bafff5c81f52204f206e2f90d24bc504ce33b4a13473c04d5a4f896f815ea26d68b95440d07dd076dd2ea785cd7d3
|
7
|
+
data.tar.gz: 1b5499f8123d85bcbd9f4b68fece8269f8471e32e2e8d130a30fd69170aa70c0be5c3c0c5fb6a3263fd4b680111bfeec56194862fafe83f9a6f08f00926f54d4
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
+
## 1.1.1
|
4
|
+
|
5
|
+
* FIX: issues with handling time zone in daily occurrences and queries
|
6
|
+
* ADD: validation on `Occurrence` for `dtend` being after `dtstart`
|
7
|
+
|
3
8
|
## 1.1.0
|
4
9
|
|
5
10
|
* CHANGE: `#embedded_in_event` requires `name` (`#embedded_in_event(name, options)`)
|
@@ -3,9 +3,7 @@ module MongoidOccurrences
|
|
3
3
|
module HasDailyOccurrences
|
4
4
|
def daily_occurrences
|
5
5
|
adjust_dates_for_all_day!
|
6
|
-
|
7
|
-
daily_occurrences_from_schedule +
|
8
|
-
daily_occurrences_from_date_range
|
6
|
+
daily_occurrences_from_schedule + daily_occurrences_from_date_range
|
9
7
|
end
|
10
8
|
|
11
9
|
private
|
@@ -13,14 +11,11 @@ module MongoidOccurrences
|
|
13
11
|
def daily_occurrences_from_schedule
|
14
12
|
return [] unless dtstart? && dtend?
|
15
13
|
return [] unless recurring?
|
16
|
-
|
17
14
|
schedule.occurrences(schedule_dtend).map do |occurrence|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
operator: operator
|
23
|
-
)
|
15
|
+
occurrence_dtstart = occurrence.start_time.in_time_zone(Time.zone).change(hour: dtstart.hour, minute: dtstart.minute)
|
16
|
+
occurrence_dtend = occurrence.end_time.in_time_zone(Time.zone).change(hour: dtend.hour, minute: dtend.minute)
|
17
|
+
|
18
|
+
build_daily_occurrence(occurrence_dtstart, occurrence_dtend, id, operator)
|
24
19
|
end
|
25
20
|
end
|
26
21
|
|
@@ -32,17 +27,15 @@ module MongoidOccurrences
|
|
32
27
|
is_single_day = (date_range.first == date_range.last)
|
33
28
|
|
34
29
|
date_range.map do |date|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
MongoidOccurrences::DailyOccurrence.new(
|
39
|
-
dtstart: occurence_dtstart,
|
40
|
-
dtend: occurence_dtend,
|
41
|
-
occurrence_id: id,
|
42
|
-
operator: operator
|
43
|
-
)
|
30
|
+
occurrence_dtstart = is_single_day || date == date_range.first ? dtstart : date.beginning_of_day
|
31
|
+
occurrence_dtend = is_single_day || date == date_range.last ? dtend : date.end_of_day
|
32
|
+
build_daily_occurrence(occurrence_dtstart, occurrence_dtend, id, operator)
|
44
33
|
end
|
45
34
|
end
|
35
|
+
|
36
|
+
def build_daily_occurrence(dtstart, dtend, occurrence_id, operator)
|
37
|
+
MongoidOccurrences::DailyOccurrence.new(dtstart: dtstart, dtend: dtend, occurrence_id: occurrence_id, operator: operator)
|
38
|
+
end
|
46
39
|
end
|
47
40
|
end
|
48
41
|
end
|
@@ -30,6 +30,8 @@ module MongoidOccurrences
|
|
30
30
|
|
31
31
|
validates :dtstart, presence: true
|
32
32
|
validates :dtend, presence: true
|
33
|
+
|
34
|
+
validate :dtend_must_be_after_dtstart
|
33
35
|
end
|
34
36
|
end
|
35
37
|
|
@@ -49,5 +51,15 @@ module MongoidOccurrences
|
|
49
51
|
self.dtstart = dtstart.beginning_of_day
|
50
52
|
self.dtend = dtend.end_of_day
|
51
53
|
end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
def dtend_must_be_after_dtstart
|
58
|
+
return unless dtstart.present? && dtend.present?
|
59
|
+
|
60
|
+
if dtend < dtstart
|
61
|
+
errors.add(:dtend, :must_be_after_dtstart)
|
62
|
+
end
|
63
|
+
end
|
52
64
|
end
|
53
65
|
end
|
@@ -14,8 +14,8 @@ module MongoidOccurrences
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def criteria
|
17
|
-
base_criteria.lte(dtstart_field => adjusted_dtend)
|
18
|
-
.gte(dtend_field => adjusted_dtstart)
|
17
|
+
base_criteria.lte(dtstart_field => adjusted_dtend.utc)
|
18
|
+
.gte(dtend_field => adjusted_dtstart.utc)
|
19
19
|
end
|
20
20
|
|
21
21
|
private
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongoid_occurrences
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomas Celizna
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-01-
|
12
|
+
date: 2019-01-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ice_cube
|