Make sure they don't overlap on creation

This commit is contained in:
Jorge Manrubia
2025-08-26 16:59:01 +02:00
parent 8ba6f5fe8e
commit 0126aed6d7
+1 -1
View File
@@ -4,7 +4,7 @@ class Notification::Bundle < ApplicationRecord
enum :status, %i[ pending processing delivered ]
scope :due, -> { pending.where("ends_at <= ?", Time.current) }
scope :containing, -> (notification) { where("starts_at <= ? AND ends_at >= ?", notification.created_at, notification.created_at) }
scope :containing, -> (notification) { where("starts_at <= ? AND ends_at > ?", notification.created_at, notification.created_at) }
scope :overlapping_with, -> (other_bundle) {
where(
"(starts_at <= ? AND ends_at >= ?) OR (starts_at <= ? AND ends_at >= ?) OR (starts_at >= ? AND ends_at <= ?)",