Renamed status ready_to_pickup to just pickup
This commit is contained in:
@@ -19,13 +19,13 @@ class Job < ApplicationRecord
|
||||
enum status: {
|
||||
open: 0,
|
||||
printing: 1,
|
||||
ready_for_pickup: 2,
|
||||
pickup: 2,
|
||||
paid: 3,
|
||||
canceled: 4
|
||||
}
|
||||
|
||||
# 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]) }
|
||||
scope :in_status_order, -> { in_order_of(:status, %w[open printing pickup paid canceled]) }
|
||||
|
||||
scope :created_today, -> { created_on_day(Time.now) }
|
||||
scope :created_on_day, lambda { |date|
|
||||
@@ -35,12 +35,12 @@ class Job < ApplicationRecord
|
||||
scope :upgraded_on_day, lambda { |date|
|
||||
where("upgraded_at >= ? AND upgraded_at <= ?", date.beginning_of_day, date.end_of_day)
|
||||
}
|
||||
# Returns all jobs with status: open print ready_for_pickup and jobs from today with status: paid canceled
|
||||
# Returns all jobs with status: open print pickup and jobs from today with status: paid canceled
|
||||
# paid: only updated_at today
|
||||
# canceled: only updated_at today
|
||||
def self.currently_working_on
|
||||
# NOTE: use Time.now instead of Date.today to take the timezone into account
|
||||
where(status: %i[open printing ready_for_pickup])
|
||||
where(status: %i[open printing pickup])
|
||||
.or(Job.where(status: %i[paid canceled])
|
||||
.where("status_changed_at >= ?", Time.now.beginning_of_day))
|
||||
# .in_status_order
|
||||
@@ -76,7 +76,7 @@ class Job < ApplicationRecord
|
||||
private
|
||||
|
||||
def update_printed_at
|
||||
self.printed_at = Time.now if ready_for_pickup? || (paid? && printed_at.nil?)
|
||||
self.printed_at = Time.now if pickup? || (paid? && printed_at.nil?)
|
||||
end
|
||||
|
||||
def update_paid_at
|
||||
|
||||
Reference in New Issue
Block a user