Skip to content

Commit

Permalink
Add version field to object, but only use it if you are User 1
Browse files Browse the repository at this point in the history
  • Loading branch information
mo-nathan committed Aug 1, 2024
1 parent e57e46e commit 0740f3c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 6 additions & 1 deletion app/models/field_slip_job_tracker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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|
Expand Down

0 comments on commit 0740f3c

Please sign in to comment.