Some layout and model changes
This commit is contained in:
@@ -2,21 +2,31 @@ 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
|
||||
# NOTE: Multiple status if paing before brinting?
|
||||
enum status: {
|
||||
open: 0,
|
||||
printing: 1,
|
||||
ready_for_pickup: 2,
|
||||
paid: 3,
|
||||
cancelled: 4
|
||||
canceled: 4
|
||||
}
|
||||
|
||||
# BUG: shows the hole day of the utc timezone
|
||||
scope :today, -> { where('DATE(created_at) = ?', Time.now.utc.to_date) }
|
||||
scope :of_the_day, ->(date) { where('created_at >= ? AND created_at <= ?', date.beginning_of_day, date.end_of_day) }
|
||||
scope :of_today, -> { of_the_day(Time.now) }
|
||||
# NOTE: only named status are returned because of WHERE/IN clause for the enum values
|
||||
scope :in_status_order, -> { in_order_of(:status, %w[open printing ready_for_pickup paid canceled]) }
|
||||
|
||||
def self.current_jobs
|
||||
today.order(created_at: :desc, status: :asc)
|
||||
# today.order(created_at: :desc, status: :asc)
|
||||
# TODO: add logic (all with status: open, printing, ready_for_pickup. with status paid and canceled only from today)
|
||||
scope :done_on_day, ->(date) { where('created_at >= ? AND created_at <= ?', date.beginning_of_day, date.end_of_day) }
|
||||
|
||||
def self.current_jobs_of_today
|
||||
# NOTE: use Time.now instead of Date.today to take the timezone into account
|
||||
of_the_day(Time.now).in_status_order
|
||||
end
|
||||
|
||||
def self.current_jobs_of_(date)
|
||||
# NOTE: use Time.now instead of Date.today to take the timezone into account
|
||||
of_the_day(date).in_status_order
|
||||
end
|
||||
|
||||
def fullname
|
||||
|
||||
Reference in New Issue
Block a user