class Job < ApplicationRecord belongs_to :operator, class_name: 'User', optional: true belongs_to :costumer, class_name: 'User', optional: true # NOTE: Multiple status if paing before brinting enum status: { open: 0, printing: 1, ready_for_pickup: 2, paid: 3, cancelled: 4 } # BUG: shows the hole day of the utc timezone scope :today, -> { where('DATE(created_at) = ?', Time.now.utc.to_date) } def self.current_jobs today.order(created_at: :desc, status: :asc) # today.order(created_at: :desc, status: :asc) end def fullname [costumer_firstname, ' ', costumer_lastname].join end end