Sha256: 755d49c993dc74857ce57c857776146503d2f2293c08e81e074e453efc089be8

Contents?: true

Size: 658 Bytes

Versions: 11

Compression:

Stored size: 658 Bytes

Contents

class BusList < ApplicationRecord
  validates_presence_of :name, :capacity
  validates_uniqueness_of :name

  has_many :questionnaires

  strip_attributes

  def full?
    passengers.count >= capacity
  end

  def passengers
    questionnaires.where("acc_status = 'rsvp_confirmed'").order("last_name ASC")
  end

  def schools
    passengers.joins(:school).map(&:school).uniq
  end

  def checked_in_passengers
    passengers.select(&:checked_in?)
  end

  def boarded_passengers
    passengers.select(&:boarded_bus?)
  end

  def captains
    passengers.where(is_bus_captain: true)
  end

  def name_maybe_full
    full? ? "(full) #{name}" : name
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
hackathon_manager-0.14.1 app/models/bus_list.rb
hackathon_manager-0.14.0 app/models/bus_list.rb
hackathon_manager-0.13.12 app/models/bus_list.rb
hackathon_manager-0.13.11 app/models/bus_list.rb
hackathon_manager-0.13.10 app/models/bus_list.rb
hackathon_manager-0.13.9 app/models/bus_list.rb
hackathon_manager-0.13.8 app/models/bus_list.rb
hackathon_manager-0.13.7 app/models/bus_list.rb
hackathon_manager-0.13.6 app/models/bus_list.rb
hackathon_manager-0.13.5 app/models/bus_list.rb
hackathon_manager-0.13.4 app/models/bus_list.rb