Class: SchedulerBookingPage

Inherits:
ApplicationRecord show all
Extended by:
FriendlyId
Defined in:
app/models/scheduler_booking_page.rb

Overview

== Schema Information

Table name: scheduler_booking_pages
Database name: primary

id :bigint not null, primary key
active :boolean default(TRUE), not null
buffer_after_minutes :integer default(0), not null
buffer_before_minutes :integer default(0), not null
color :string
description :text
duration_minutes :integer default(30), not null
host_assignment_strategy :string default("single"), not null
invite_customer_sales_rep :boolean default(FALSE), not null
location_type :string default("phone"), not null
max_days_ahead :integer default(30), not null
min_notice_hours :integer default(4), not null
name :string not null
slug :string not null
created_at :datetime not null
updated_at :datetime not null

Indexes

index_scheduler_booking_pages_on_active (active)
index_scheduler_booking_pages_on_slug (slug) UNIQUE

Instance Attribute Summary collapse

Has many collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApplicationRecord

ransackable_associations, ransackable_attributes, ransackable_scopes, ransortable_attributes, #to_relation

Methods included from Models::EventPublishable

#publish_event

Instance Attribute Details

#buffer_after_minutesObject (readonly)



41
# File 'app/models/scheduler_booking_page.rb', line 41

validates :buffer_before_minutes, :buffer_after_minutes, numericality: { greater_than_or_equal_to: 0 }

#buffer_before_minutesObject (readonly)



41
# File 'app/models/scheduler_booking_page.rb', line 41

validates :buffer_before_minutes, :buffer_after_minutes, numericality: { greater_than_or_equal_to: 0 }

#duration_minutesObject (readonly)



40
# File 'app/models/scheduler_booking_page.rb', line 40

validates :duration_minutes, presence: true, numericality: { greater_than: 0 }

#host_assignment_strategyObject (readonly)



45
# File 'app/models/scheduler_booking_page.rb', line 45

validates :host_assignment_strategy, presence: true, inclusion: { in: %w[single round_robin] }

#location_typeObject (readonly)



44
# File 'app/models/scheduler_booking_page.rb', line 44

validates :location_type, presence: true, inclusion: { in: %w[phone zoom customer_choice] }

#max_days_aheadObject (readonly)



43
# File 'app/models/scheduler_booking_page.rb', line 43

validates :max_days_ahead, numericality: { greater_than: 0 }

#min_notice_hoursObject (readonly)



42
# File 'app/models/scheduler_booking_page.rb', line 42

validates :min_notice_hours, numericality: { greater_than_or_equal_to: 0 }

#nameObject (readonly)



39
# File 'app/models/scheduler_booking_page.rb', line 39

validates :name, presence: true, uniqueness: true

Class Method Details

.activeActiveRecord::Relation<SchedulerBookingPage>

A relation of SchedulerBookingPages that are active. Active Record Scope

Returns:

See Also:



47
# File 'app/models/scheduler_booking_page.rb', line 47

scope :active, -> { where(active: true) }

Instance Method Details

#active_hostsObject



68
69
70
# File 'app/models/scheduler_booking_page.rb', line 68

def active_hosts
  scheduler_hosts.joins(:employee).merge(Employee.active_employees).order(:priority)
end

#customer_choice?Boolean

Returns:

  • (Boolean)


64
65
66
# File 'app/models/scheduler_booking_page.rb', line 64

def customer_choice?
  location_type == 'customer_choice'
end

#employeesActiveRecord::Relation<Employee>

Returns:

See Also:



35
# File 'app/models/scheduler_booking_page.rb', line 35

has_many :employees, through: :scheduler_hosts

#round_robin?Boolean

Returns:

  • (Boolean)


60
61
62
# File 'app/models/scheduler_booking_page.rb', line 60

def round_robin?
  host_assignment_strategy == 'round_robin'
end

#scheduler_booking_questionsActiveRecord::Relation<SchedulerBookingQuestion>

Returns:

See Also:



37
# File 'app/models/scheduler_booking_page.rb', line 37

has_many :scheduler_booking_questions, -> { ordered }, dependent: :destroy

#scheduler_bookingsActiveRecord::Relation<SchedulerBooking>

Returns:

See Also:



36
# File 'app/models/scheduler_booking_page.rb', line 36

has_many :scheduler_bookings, dependent: :destroy

#scheduler_hostsActiveRecord::Relation<SchedulerHost>

Returns:

See Also:



34
# File 'app/models/scheduler_booking_page.rb', line 34

has_many :scheduler_hosts, dependent: :destroy

#should_generate_new_friendly_id?Boolean

Returns:

  • (Boolean)


52
53
54
# File 'app/models/scheduler_booking_page.rb', line 52

def should_generate_new_friendly_id?
  slug.blank? || will_save_change_to_attribute?(:name)
end

#single_host?Boolean

Returns:

  • (Boolean)


56
57
58
# File 'app/models/scheduler_booking_page.rb', line 56

def single_host?
  host_assignment_strategy == 'single'
end