diff --git a/app/services/footprint_service.rb b/app/services/footprint_service.rb index db8b59fc0..21677f2b1 100644 --- a/app/services/footprint_service.rb +++ b/app/services/footprint_service.rb @@ -48,16 +48,20 @@ class FootprintService columns = FootprintService.footprint_columns(klass) current = FootprintService.footprint_data(klass, item, array: true) saved = FootprintDebug.find_by(footprint: item.footprint, klass: klass.name) - others = FootprintDebug.where('klass = ? AND data LIKE ? AND id != ?', klass, "#{item.id}%", saved.id) - puts "Debug footprint for #{klass} [ id: #{item.id} ]" - puts '-----------------------------------------' - puts "columns: [ #{columns.join(', ')} ]" - puts "current: #{current}" - puts " saved: #{saved.format_data(item.id)}" - puts '-----------------------------------------' - puts "other possible matches IDs: #{others.map(&:id)}" - puts '-----------------------------------------' - item.footprint_children.map(&:debug_footprint) + if saved.nil? + puts "Debug data not found for #{klass} [ id: #{item.id} ]" + else + others = FootprintDebug.where('klass = ? AND data LIKE ? AND id != ?', klass, "#{item.id}%", saved.id) + puts "Debug footprint for #{klass} [ id: #{item.id} ]" + puts '-----------------------------------------' + puts "columns: [ #{columns.join(', ')} ]" + puts "current: #{current}" + puts " saved: #{saved.format_data(item.id)}" + puts '-----------------------------------------' + puts "other possible matches IDs: #{others.map(&:id)}" + puts '-----------------------------------------' + item.footprint_children.map(&:debug_footprint) + end end private diff --git a/lib/integrity/archive_helper.rb b/lib/integrity/archive_helper.rb index 4b3e1b396..42695252a 100644 --- a/lib/integrity/archive_helper.rb +++ b/lib/integrity/archive_helper.rb @@ -15,7 +15,7 @@ class Integrity::ArchiveHelper Invoice.where('created_at > ?', last_period.end_at).order(:id).each do |i| next if i.check_footprint - puts i.debug_footprint + i.debug_footprint raise "Invalid footprint for invoice #{i.id}" end else @@ -23,7 +23,7 @@ class Integrity::ArchiveHelper Invoice.order(:id).all.each do |i| next if i.check_footprint - puts i.debug_footprint + i.debug_footprint raise "Invalid footprint for invoice #{i.id}" end end