2019-02-12 14:45:21 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
namespace :fablab do
|
|
|
|
namespace :setup do
|
|
|
|
desc 'assign all footprints to existing Invoice records'
|
|
|
|
task chain_invoices_records: :environment do
|
2019-02-13 10:59:44 +01:00
|
|
|
raise "Footprints were already generated, won't regenerate" if Invoice.where.not(footprint: nil).count.positive?
|
|
|
|
|
2019-03-11 13:49:16 +01:00
|
|
|
Invoice.order(:created_at).all.each(&:chain_record)
|
2019-02-12 14:45:21 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
desc 'assign all footprints to existing InvoiceItem records'
|
|
|
|
task chain_invoices_items_records: :environment do
|
2019-02-13 10:59:44 +01:00
|
|
|
raise "Footprints were already generated, won't regenerate" if InvoiceItem.where.not(footprint: nil).count.positive?
|
|
|
|
|
2019-03-11 13:49:16 +01:00
|
|
|
InvoiceItem.order(:created_at).all.each(&:chain_record)
|
2019-02-12 14:45:21 +01:00
|
|
|
end
|
2019-02-27 17:44:52 +01:00
|
|
|
|
|
|
|
desc 'assign environment value to all invoices'
|
|
|
|
task set_environment_to_invoices: :environment do
|
|
|
|
Invoice.all.each do |i|
|
|
|
|
i.environment = Rails.env
|
|
|
|
i.save!
|
|
|
|
end
|
|
|
|
end
|
2019-02-12 14:45:21 +01:00
|
|
|
end
|
2019-02-13 10:59:44 +01:00
|
|
|
end
|