From 0740f3ca69375e374aa24a011cc2c4e4d1c79cc3 Mon Sep 17 00:00:00 2001 From: Nathan Wilson Date: Thu, 1 Aug 2024 16:41:58 -0400 Subject: [PATCH] Add version field to object, but only use it if you are User 1 --- app/models/field_slip_job_tracker.rb | 7 ++++++- db/schema.rb | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/models/field_slip_job_tracker.rb b/app/models/field_slip_job_tracker.rb index 056ea6df58..0baed7ac4f 100644 --- a/app/models/field_slip_job_tracker.rb +++ b/app/models/field_slip_job_tracker.rb @@ -15,6 +15,7 @@ class FieldSlipJobTracker < AbstractModel belongs_to :user def self.create(*args) + args[0][:version] = 2 if User.current.id == 1 args[0][:status] = "Starting" super(*args) end @@ -34,7 +35,11 @@ def done end def filename - @filename ||= "#{prefix}-#{code_num(start)}-#{code_num(last)}-#{id}.pdf" + @filename ||= if version == 1 + "#{prefix}-#{code_num(start)}-#{code_num(last)}-#{id}.pdf" + else + "MO-#{id}.pdf" + end end def filepath diff --git a/db/schema.rb b/db/schema.rb index 8b0850a208..53a1d97ec7 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.1].define(version: 2024_06_08_213317) do +ActiveRecord::Schema[7.1].define(version: 2024_08_01_202223) do create_table "api_keys", id: :integer, charset: "utf8mb3", force: :cascade do |t| t.datetime "created_at", precision: nil t.datetime "last_used", precision: nil @@ -96,6 +96,7 @@ t.string "title", limit: 100, default: "", null: false t.integer "user_id" t.boolean "one_per_page", default: false, null: false + t.integer "version", default: 1 end create_table "field_slips", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|