DEV: 'expired' and 'not_expired' scopes must cover all events

DEV: ‘expired’ and ‘not_expired’ scopes must cover all events

diff --git a/app/models/discourse_post_event/event.rb b/app/models/discourse_post_event/event.rb
index 02a9ac2..f413038 100644
--- a/app/models/discourse_post_event/event.rb
+++ b/app/models/discourse_post_event/event.rb
@@ -38,13 +38,9 @@ module DiscoursePostEvent
     belongs_to :post, foreign_key: :id
 
     scope :visible, -> { where(deleted_at: nil) }
-    scope :expired, -> { where('COALESCE(ends_at, starts_at) < ?', Time.now) }
-    scope :not_expired, -> {
-      where(<<-SQL, now: Time.now)
-        (ends_at IS NOT NULL AND ends_at > :now) OR
-        (starts_at > :now AND ends_at IS NULL)
-      SQL
-    }
+
+    scope :expired,     -> { where('COALESCE(ends_at, starts_at) < ?',  Time.now) }
+    scope :not_expired, -> { where('COALESCE(ends_at, starts_at) >= ?', Time.now) }
 
     def is_expired?
       self.ends_at.present? ? Time.now > self.ends_at : Time.now > self.starts_at

GitHub sha: a34f410c