mirror of
https://github.com/internetee/registry.git
synced 2025-07-23 03:06:14 +02:00
111864739-legal_doc_for_pt
This commit is contained in:
parent
e7aef75b25
commit
07d6805aa6
3 changed files with 45 additions and 0 deletions
41
lib/tasks/documents.rake
Normal file
41
lib/tasks/documents.rake
Normal file
|
@ -0,0 +1,41 @@
|
|||
namespace :documents do
|
||||
|
||||
|
||||
desc 'Generate all'
|
||||
task all: :environment do
|
||||
Rake::Task['documents:log'].invoke
|
||||
end
|
||||
|
||||
desc 'Generate legaldoc versions'
|
||||
task log: :environment do
|
||||
start = Time.zone.now.to_f
|
||||
puts '-----> Adding documets id for PaperTrail log...'
|
||||
count = 0
|
||||
|
||||
LegalDocument.all.each do |x|
|
||||
|
||||
next if x.documentable_id.blank?
|
||||
|
||||
dc = DomainVersion.where(item_id: x.documentable_id)
|
||||
|
||||
dc.each do |y|
|
||||
|
||||
if x.created_at < (y.created_at + (2*60)) &&
|
||||
x.created_at > (y.created_at - (2*60))
|
||||
|
||||
y.children[:legal_documents] = [x.id]
|
||||
y.save
|
||||
count =+1
|
||||
|
||||
else
|
||||
|
||||
y.children[:legal_documents] = []
|
||||
y.save
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
puts "-----> Log changed for #{count} rows in #{(Time.zone.now.to_f - start).round(2)} seconds"
|
||||
end
|
||||
end
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue