2020-12-18 09:03:51 -06:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class DoNotDisturbTiming < ActiveRecord::Base
|
|
|
|
belongs_to :user
|
|
|
|
|
2022-02-27 20:20:58 -06:00
|
|
|
validate :ends_at_greater_than_starts_at
|
2020-12-18 09:03:51 -06:00
|
|
|
|
2022-02-27 20:20:58 -06:00
|
|
|
def ends_at_greater_than_starts_at
|
2023-01-09 06:20:10 -06:00
|
|
|
errors.add(:ends_at, :invalid) if starts_at > ends_at
|
2020-12-18 09:03:51 -06:00
|
|
|
end
|
|
|
|
end
|
2021-07-05 17:14:15 -05:00
|
|
|
|
|
|
|
# == Schema Information
|
|
|
|
#
|
|
|
|
# Table name: do_not_disturb_timings
|
|
|
|
#
|
|
|
|
# id :bigint not null, primary key
|
|
|
|
# user_id :integer not null
|
|
|
|
# starts_at :datetime not null
|
|
|
|
# ends_at :datetime not null
|
|
|
|
# scheduled :boolean default(FALSE)
|
|
|
|
#
|
|
|
|
# Indexes
|
|
|
|
#
|
|
|
|
# index_do_not_disturb_timings_on_ends_at (ends_at)
|
|
|
|
# index_do_not_disturb_timings_on_scheduled (scheduled)
|
|
|
|
# index_do_not_disturb_timings_on_starts_at (starts_at)
|
|
|
|
# index_do_not_disturb_timings_on_user_id (user_id)
|
|
|
|
#
|