mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-02-17 11:54:22 +01:00
generate footprints in a reproductible way
This commit is contained in:
parent
36e173fb43
commit
55b0e25ee9
@ -7,6 +7,7 @@
|
||||
- Improved the development and production documentations
|
||||
- Improved the style of the titles of the subscription page
|
||||
- Check the status of the assets' compilation during the upgrade
|
||||
- Footprints are now generated in a more reproductible way
|
||||
- Fix a bug: build status badge is not working
|
||||
- Fix a bug: unable to set date formats during installation
|
||||
- Fix a bug: unable to cancel the upgrade before it begins
|
||||
@ -17,6 +18,7 @@
|
||||
- [BREAKING CHANGE] GET `open_api/v1/invoices` won't return `invoiced_id`, `invoiced_type` OR `invoiced.created_at` anymore. The new field `main_object` will contain the equivalent data.
|
||||
- [TODO DEPLOY] `rails fablab:stripe:set_gateway`
|
||||
- [TODO DEPLOY] `rails fablab:maintenance:rebuild_stylesheet`
|
||||
- [TODO DEPLOY] `rails fablab:chain:all`
|
||||
- [TODO DEPLOY] `\curl -sSL https://raw.githubusercontent.com/sleede/fab-manager/master/scripts/rename-adminsys.sh | bash`
|
||||
|
||||
## v4.7.11 2021 May 26
|
||||
|
@ -38,7 +38,7 @@ class FootprintService
|
||||
# Return an ordered array of the columns used in the footprint computation
|
||||
# @param klass {Class} a class inheriting from Footprintable
|
||||
def footprint_columns(klass)
|
||||
klass.columns.map(&:name).delete_if { |c| %w[footprint updated_at].concat(klass.columns_out_of_footprint).include? c }
|
||||
klass.columns.map(&:name).delete_if { |c| %w[footprint updated_at].concat(klass.columns_out_of_footprint).include? c }.sort
|
||||
end
|
||||
|
||||
# Logs a debugging message to help finding why a footprint is invalid
|
||||
|
@ -5213,6 +5213,14 @@ CREATE INDEX profiles_lower_unaccent_last_name_trgm_idx ON public.profiles USING
|
||||
CREATE INDEX projects_search_vector_idx ON public.projects USING gin (search_vector);
|
||||
|
||||
|
||||
--
|
||||
-- Name: accounting_periods accounting_periods_del_protect; Type: RULE; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE RULE accounting_periods_del_protect AS
|
||||
ON DELETE TO public.accounting_periods DO INSTEAD NOTHING;
|
||||
|
||||
|
||||
--
|
||||
-- Name: projects projects_search_content_trigger; Type: TRIGGER; Schema: public; Owner: -
|
||||
--
|
||||
|
140
lib/tasks/fablab/chain.rake
Normal file
140
lib/tasks/fablab/chain.rake
Normal file
@ -0,0 +1,140 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
namespace :fablab do
|
||||
namespace :chain do
|
||||
desc 'assign all footprints to existing records'
|
||||
task all: :environment do
|
||||
if Invoice.where.not(footprint: nil).count.positive?
|
||||
print 'All footprints will be regenerated. Are you sure? (y/n) '
|
||||
confirm = STDIN.gets.chomp
|
||||
next unless confirm == 'y'
|
||||
end
|
||||
chain_invoices
|
||||
chain_invoice_items
|
||||
chain_history_values
|
||||
chain_payment_schedules
|
||||
chain_payment_schedules_items
|
||||
chain_payment_schedules_objects if ActiveRecord::Base.connection.table_exists? PaymentScheduleObject.arel_table
|
||||
end
|
||||
|
||||
|
||||
desc 'assign all footprints to existing Invoice records'
|
||||
task invoices: :environment do
|
||||
if Invoice.where.not(footprint: nil).count.positive?
|
||||
print 'WARNING: Footprints were already generated. Regenerate? (y/n) '
|
||||
confirm = STDIN.gets.chomp
|
||||
next unless confirm == 'y'
|
||||
end
|
||||
chain_invoices
|
||||
end
|
||||
|
||||
def chain_invoices
|
||||
if AccountingPeriod.count.positive?
|
||||
last_period = AccountingPeriod.order(start_at: :desc).first
|
||||
puts "Regenerating from #{last_period.end_at}..."
|
||||
Invoice.where('created_at > ?', last_period.end_at).order(:id).each(&:chain_record)
|
||||
else
|
||||
puts '(Re)generating all footprint...'
|
||||
Invoice.order(:id).all.each(&:chain_record)
|
||||
end
|
||||
end
|
||||
|
||||
desc 'assign all footprints to existing InvoiceItem records'
|
||||
task invoices_items: :environment do
|
||||
if InvoiceItem.where.not(footprint: nil).count.positive?
|
||||
print 'WARNING: Footprints were already generated. Regenerate? (y/n) '
|
||||
confirm = STDIN.gets.chomp
|
||||
next unless confirm == 'y'
|
||||
end
|
||||
chain_invoice_items
|
||||
end
|
||||
|
||||
def chain_invoice_items
|
||||
if AccountingPeriod.count.positive?
|
||||
last_period = AccountingPeriod.order(start_at: :desc).first
|
||||
puts "Regenerating from #{last_period.end_at}..."
|
||||
InvoiceItem.where('created_at > ?', last_period.end_at).order(:id).each(&:chain_record)
|
||||
else
|
||||
puts '(Re)generating all footprint...'
|
||||
InvoiceItem.order(:id).all.each(&:chain_record)
|
||||
end
|
||||
end
|
||||
|
||||
desc 'assign all footprints to existing HistoryValue records'
|
||||
task history_values: :environment do
|
||||
if HistoryValue.where.not(footprint: nil).count.positive?
|
||||
print 'WARNING: Footprints were already generated. Regenerate? (y/n) '
|
||||
confirm = STDIN.gets.chomp
|
||||
next unless confirm == 'y'
|
||||
end
|
||||
chain_history_values
|
||||
end
|
||||
|
||||
def chain_history_values
|
||||
HistoryValue.order(:id).all.each(&:chain_record)
|
||||
end
|
||||
|
||||
desc 'assign all footprints to existing PaymentSchedule records'
|
||||
task payment_schedule: :environment do
|
||||
if PaymentSchedule.where.not(footprint: nil).count.positive?
|
||||
print 'WARNING: Footprints were already generated. Regenerate? (y/n) '
|
||||
confirm = STDIN.gets.chomp
|
||||
next unless confirm == 'y'
|
||||
end
|
||||
chain_payment_schedules
|
||||
end
|
||||
|
||||
def chain_payment_schedules
|
||||
if AccountingPeriod.count.positive?
|
||||
last_period = AccountingPeriod.order(start_at: :desc).first
|
||||
puts "Regenerating from #{last_period.end_at}..."
|
||||
PaymentSchedule.where('created_at > ?', last_period.end_at).order(:id).each(&:chain_record)
|
||||
else
|
||||
puts '(Re)generating all footprint...'
|
||||
PaymentSchedule.order(:id).all.each(&:chain_record)
|
||||
end
|
||||
end
|
||||
|
||||
desc 'assign all footprints to existing PaymentScheduleItem records'
|
||||
task payment_schedule_item: :environment do
|
||||
if PaymentScheduleItem.where.not(footprint: nil).count.positive?
|
||||
print 'WARNING: Footprints were already generated. Regenerate? (y/n) '
|
||||
confirm = STDIN.gets.chomp
|
||||
next unless confirm == 'y'
|
||||
end
|
||||
chain_payment_schedules_items
|
||||
end
|
||||
|
||||
def chain_payment_schedules_items
|
||||
if AccountingPeriod.count.positive?
|
||||
last_period = AccountingPeriod.order(start_at: :desc).first
|
||||
puts "Regenerating from #{last_period.end_at}..."
|
||||
PaymentScheduleItem.where('created_at > ?', last_period.end_at).order(:id).each(&:chain_record)
|
||||
else
|
||||
puts '(Re)generating all footprint...'
|
||||
PaymentScheduleItem.order(:id).all.each(&:chain_record)
|
||||
end
|
||||
end
|
||||
|
||||
desc 'assign all footprints to existing PaymentScheduleObject records'
|
||||
task payment_schedule_object: :environment do
|
||||
if PaymentScheduleObject.where.not(footprint: nil).count.positive?
|
||||
print 'WARNING: Footprints were already generated. Regenerate? (y/n) '
|
||||
confirm = STDIN.gets.chomp
|
||||
next unless confirm == 'y'
|
||||
end
|
||||
chain_payment_schedules_objects
|
||||
end
|
||||
|
||||
def chain_payment_schedules_objects
|
||||
if AccountingPeriod.count.positive?
|
||||
last_period = AccountingPeriod.order(start_at: :desc).first
|
||||
puts "Regenerating from #{last_period.end_at}..."
|
||||
PaymentScheduleObject.where('created_at > ?', last_period.end_at).order(:id).each(&:chain_record)
|
||||
else
|
||||
puts '(Re)generating all footprint...'
|
||||
PaymentScheduleObject.order(:id).all.each(&:chain_record)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -2,53 +2,6 @@
|
||||
|
||||
namespace :fablab do
|
||||
namespace :setup do
|
||||
desc 'assign all footprints to existing Invoice records'
|
||||
task chain_invoices_records: :environment do
|
||||
if Invoice.where.not(footprint: nil).count.positive?
|
||||
print 'WARNING: Footprints were already generated. Regenerate? (y/n) '
|
||||
confirm = STDIN.gets.chomp
|
||||
next unless confirm == 'y'
|
||||
end
|
||||
|
||||
if AccountingPeriod.count.positive?
|
||||
last_period = AccountingPeriod.order(start_at: :desc).first
|
||||
puts "Regenerating from #{last_period.end_at}..."
|
||||
Invoice.where('created_at > ?', last_period.end_at).order(:id).each(&:chain_record)
|
||||
else
|
||||
puts '(Re)generating all footprint...'
|
||||
Invoice.order(:id).all.each(&:chain_record)
|
||||
end
|
||||
end
|
||||
|
||||
desc 'assign all footprints to existing InvoiceItem records'
|
||||
task chain_invoices_items_records: :environment do
|
||||
if InvoiceItem.where.not(footprint: nil).count.positive?
|
||||
print 'WARNING: Footprints were already generated. Regenerate? (y/n) '
|
||||
confirm = STDIN.gets.chomp
|
||||
next unless confirm == 'y'
|
||||
end
|
||||
|
||||
if AccountingPeriod.count.positive?
|
||||
last_period = AccountingPeriod.order(start_at: :desc).first
|
||||
puts "Regenerating from #{last_period.end_at}..."
|
||||
InvoiceItem.where('created_at > ?', last_period.end_at).order(:id).each(&:chain_record)
|
||||
else
|
||||
puts '(Re)generating all footprint...'
|
||||
InvoiceItem.order(:id).all.each(&:chain_record)
|
||||
end
|
||||
end
|
||||
|
||||
desc 'assign all footprints to existing HistoryValue records'
|
||||
task chain_history_values_records: :environment do
|
||||
if HistoryValue.where.not(footprint: nil).count.positive?
|
||||
print 'WARNING: Footprints were already generated. Regenerate? (y/n) '
|
||||
confirm = STDIN.gets.chomp
|
||||
next unless confirm == 'y'
|
||||
end
|
||||
|
||||
HistoryValue.order(:id).all.each(&:chain_record)
|
||||
end
|
||||
|
||||
desc 'assign environment value to all invoices'
|
||||
task set_environment_to_invoices: :environment do
|
||||
Invoice.all.each do |i|
|
||||
|
1575
test/fixtures/footprint_debugs.yml
vendored
1575
test/fixtures/footprint_debugs.yml
vendored
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user