Added job attributes, fixed seeds.rb

Added some attributes like status_changed_at. Refactored migration
files.
Changes to the migration file makes it necessary to reimport the
database: db:drop, db:create, db:migrate, db:seed
This commit is contained in:
2024-08-02 13:47:44 +02:00
parent 9a3777be44
commit c5e55eb410
16 changed files with 54 additions and 32 deletions

View File

@@ -10,6 +10,7 @@ class CreateJobs < ActiveRecord::Migration[7.1]
t.boolean :printed, default: false
t.boolean :paid, default: false
t.datetime :printed_at
t.datetime :status_changed_at
t.datetime :paid_at
t.boolean :intern, default: false
t.string :cost_center
@@ -19,7 +20,7 @@ class CreateJobs < ActiveRecord::Migration[7.1]
t.integer :number_of_plans_a2, default: 0
t.integer :number_of_plans_a3, default: 0
t.float :costum_qm_plan, default: 0
t.string :pdf
t.boolean :privacy_policy_accepted, default: false
t.timestamps
end

View File

@@ -1,5 +0,0 @@
class AddPrivacyPolicyAcceptedToJob < ActiveRecord::Migration[7.1]
def change
add_column :jobs, :privacy_policy_accepted, :boolean, default: false
end
end

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
db/pdfs/GanzWichtig.pdf Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

6
db/schema.rb generated
View File

@@ -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_08_01_205025) do
ActiveRecord::Schema[7.1].define(version: 2024_08_01_153403) do
create_table "active_storage_attachments", force: :cascade do |t|
t.string "name", null: false
t.string "record_type", null: false
@@ -49,6 +49,7 @@ ActiveRecord::Schema[7.1].define(version: 2024_08_01_205025) do
t.boolean "printed", default: false
t.boolean "paid", default: false
t.datetime "printed_at"
t.datetime "status_changed_at"
t.datetime "paid_at"
t.boolean "intern", default: false
t.string "cost_center"
@@ -58,10 +59,9 @@ ActiveRecord::Schema[7.1].define(version: 2024_08_01_205025) do
t.integer "number_of_plans_a2", default: 0
t.integer "number_of_plans_a3", default: 0
t.float "costum_qm_plan", default: 0.0
t.string "pdf"
t.boolean "privacy_policy_accepted", default: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.boolean "privacy_policy_accepted", default: false
t.index ["costumer_id"], name: "index_jobs_on_costumer_id"
t.index ["operator_id"], name: "index_jobs_on_operator_id"
t.index ["status"], name: "index_jobs_on_status"

View File

@@ -15,7 +15,7 @@ Faker::Config.locale = :de
end
['GanzWichtig.pdf', 'IchBinIn5MinDran.pdf', 'DerPlanDerImmerProblemeMacht.pdf',
'DieFarbenGefallenMirNicht.pdf', 'MachHinIchHabsEilig.pdf', 'WarumDauertDasSoLange.pdf',
'DenPlanBezahleIchNicht.pdf', 'IchWarAlsErstesDran.pdf', 'WarumIstDerPlotterDefekt.pdf', 'DasNächsteMalGeheIchWoAndersHin'].shuffle.each do |pdf|
'DenPlanBezahleIchNicht.pdf', 'IchWarAlsErstesDran.pdf', 'WarumIstDerPlotterDefekt.pdf', 'DasNächsteMalGeheIchWoAndersHin.pdf'].shuffle.each do |pdf|
a0 = rand(0...7)
a1 = rand(0...7)
a2 = rand(0...7)
@@ -23,9 +23,12 @@ end
a0.zero? || a1 = 0 && a2 = 0 && a3 = 0
a1.zero? || a2 = 0 && a3 = 0
a2.zero? || a3 = 0
status = %i[open printing ready_for_pickup paid cancelled].sample
status = %i[open printing ready_for_pickup paid canceled].sample
Job.new(costumer_firstname: Faker::Name.unique.first_name, costumer_lastname: Faker::Name.unique.last_name,
number_of_plans_a0: a0, number_of_plans_a1: a1, number_of_plans_a2: a2, number_of_plans_a3: a3,
pdf:, status:).save
job = Job.new(costumer_firstname: Faker::Name.unique.first_name, costumer_lastname: Faker::Name.unique.last_name,
number_of_plans_a0: a0, number_of_plans_a1: a1, number_of_plans_a2: a2, number_of_plans_a3: a3,
status:, privacy_policy_accepted: true)
job.pdf = File.open(Rails.root.join('db/pdfs/', pdf))
job.save!
sleep 1
end