summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorerdgeist <erdgeist@erdgeist.org>2026-07-02 15:13:40 +0200
committererdgeist <erdgeist@erdgeist.org>2026-07-02 15:13:40 +0200
commit9a3274345dc83096a9bdea612ec77cb2406fef21 (patch)
tree69dbd2eddcd49a2a967b7d63a31edf845dd201fe /app
parent2c54303b1ac08ec6b7382ece218f37d59db7052c (diff)
Fix DST drift in occurrence generation
- Occurrence.generate_dates: use ChaosCalendar::occurrences_for_timezone with Time.zone.tzinfo.identifier — occurrences now keep wall-clock time across DST boundaries (19:00 stays 19:00 in summer and winter); requires chaoscalendar gem with occurrences_for_timezone support (Gemfile.lock bumped accordingly) - Occurrence.find_in_range: joins(:event) inner join excludes occurrences whose event no longer exists (107k orphaned rows from the pre-revival calendar era were purged from the test DB); includes(:node) retained for eager loading; column references qualified with table name
Diffstat (limited to 'app')
-rw-r--r--app/models/occurrence.rb12
1 files changed, 7 insertions, 5 deletions
diff --git a/app/models/occurrence.rb b/app/models/occurrence.rb
index 777be24..41ef4cb 100644
--- a/app/models/occurrence.rb
+++ b/app/models/occurrence.rb
@@ -10,9 +10,10 @@ class Occurrence < ApplicationRecord
10 # Class Methods 10 # Class Methods
11 11
12 def self.find_in_range start_time, end_time 12 def self.find_in_range start_time, end_time
13 includes(:node) 13 joins(:event)
14 .where("start_time > ? AND end_time < ?", start_time, end_time) 14 .includes(:node)
15 .order("start_time") 15 .where("occurrences.start_time > ? AND occurrences.end_time < ?", start_time, end_time)
16 .order("occurrences.start_time")
16 end 17 end
17 18
18 def self.find_next 19 def self.find_next
@@ -48,10 +49,11 @@ class Occurrence < ApplicationRecord
48 # Return value is always an array of Time objects. 49 # Return value is always an array of Time objects.
49 def self.generate_dates event 50 def self.generate_dates event
50 if event.rrule && !event.rrule.empty? 51 if event.rrule && !event.rrule.empty?
51 ChaosCalendar::occurrences( 52 ChaosCalendar::occurrences_for_timezone(
52 event.start_time, 53 event.start_time,
53 (Time.now + 5.years), 54 (Time.now + 5.years),
54 event.rrule 55 event.rrule,
56 Time.zone.tzinfo.identifier
55 ) 57 )
56 else 58 else
57 [event.start_time] 59 [event.start_time]