Added pdf analyzer

Analyzer should be moved to ActiveStorage::Analyzer
First there are many bugs with ActiveStorage that needs to be fixed:
Files are not deleted if job is destroyed (dependent: :purge is set)
If a new file is uploaded the old file is not deleted
(has_one_attechment)
This commit is contained in:
2024-08-08 13:56:36 +02:00
parent 19cf60c9a9
commit 616bd0cbe7
7 changed files with 139 additions and 14 deletions

View File

@@ -17,18 +17,18 @@ end
['GanzWichtig.pdf', 'IchBinIn5MinDran.pdf', 'DerPlanDerImmerProblemeMacht.pdf',
'DieFarbenGefallenMirNicht.pdf', 'MachHinIchHabsEilig.pdf', 'WarumDauertDasSoLange.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)
a3 = rand(0...7)
a0.zero? || a1 = 0 && a2 = 0 && a3 = 0
a1.zero? || a2 = 0 && a3 = 0
a2.zero? || a3 = 0
# a0 = rand(0...7)
# a1 = rand(0...7)
# a2 = rand(0...7)
# a3 = rand(0...7)
# a0.zero? || a1 = 0 && a2 = 0 && a3 = 0
# a1.zero? || a2 = 0 && a3 = 0
# a2.zero? || a3 = 0
status = %i[open open open open open open open open open open open open open open
printing ready_for_pickup paid canceled].sample
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,
# 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!