Renamed status ready_to_pickup to just pickup

This commit is contained in:
2024-08-11 16:53:28 +02:00
parent 6a8de20f44
commit 6522ab0339
3 changed files with 10 additions and 10 deletions

View File

@@ -19,13 +19,13 @@ class Job < ApplicationRecord
enum status: { enum status: {
open: 0, open: 0,
printing: 1, printing: 1,
ready_for_pickup: 2, pickup: 2,
paid: 3, paid: 3,
canceled: 4 canceled: 4
} }
# NOTE: only named status are returned because of WHERE/IN clause for the enum values # 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_today, -> { created_on_day(Time.now) }
scope :created_on_day, lambda { |date| scope :created_on_day, lambda { |date|
@@ -35,12 +35,12 @@ class Job < ApplicationRecord
scope :upgraded_on_day, lambda { |date| scope :upgraded_on_day, lambda { |date|
where("upgraded_at >= ? AND upgraded_at <= ?", date.beginning_of_day, date.end_of_day) 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 # paid: only updated_at today
# canceled: only updated_at today # canceled: only updated_at today
def self.currently_working_on def self.currently_working_on
# NOTE: use Time.now instead of Date.today to take the timezone into account # 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]) .or(Job.where(status: %i[paid canceled])
.where("status_changed_at >= ?", Time.now.beginning_of_day)) .where("status_changed_at >= ?", Time.now.beginning_of_day))
# .in_status_order # .in_status_order
@@ -76,7 +76,7 @@ class Job < ApplicationRecord
private private
def update_printed_at 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 end
def update_paid_at def update_paid_at

View File

@@ -23,8 +23,8 @@ module.exports = {
"status-open-light": "#d1d5db", // gray-300 "status-open-light": "#d1d5db", // gray-300
"status-printing": "#713f12", // yellow-900 "status-printing": "#713f12", // yellow-900
"status-printing-light": "#fde047", // yellow-300 "status-printing-light": "#fde047", // yellow-300
"status-ready_for_pickup": "#365314", // lime-900 "status-pickup": "#365314", // lime-900
"status-ready_for_pickup-light": "#bef264", // lime-300 "status-pickup-light": "#bef264", // lime-300
"status-paid": "#14532d", // green-900 "status-paid": "#14532d", // green-900
"status-paid-light": "#86efac", // green-300 "status-paid-light": "#86efac", // green-300
"status-canceled": "#7f1d1d", // red-900 "status-canceled": "#7f1d1d", // red-900
@@ -37,8 +37,8 @@ module.exports = {
"bg-status-open-light", "bg-status-open-light",
"text-status-printing", "text-status-printing",
"bg-status-printing-light", "bg-status-printing-light",
"text-status-ready_for_pickup", "text-status-pickup",
"bg-status-ready_for_pickup-light", "bg-status-pickup-light",
"text-status-paid", "text-status-paid",
"bg-status-paid-light", "bg-status-paid-light",
"text-status-canceled", "text-status-canceled",

2
db/schema.rb generated
View File

@@ -10,7 +10,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[7.1].define(version: 2024_08_10_095256) do ActiveRecord::Schema[7.2].define(version: 2024_08_01_153403) do
create_table "active_storage_attachments", force: :cascade do |t| create_table "active_storage_attachments", force: :cascade do |t|
t.string "name", null: false t.string "name", null: false
t.string "record_type", null: false t.string "record_type", null: false