Sha256: f186ac27fa87a8574ab127e702f1621d1f0ea7b915f6de7b558c10bde3c0464a
Contents?: true
Size: 1.13 KB
Versions: 4
Compression:
Stored size: 1.13 KB
Contents
namespace :iqvoc do namespace :cleanup do desc 'adds explicit change notes positioning numbers' task :add_change_note_positions => :environment do change_notes = Iqvoc.change_note_class.joins(:annotations) .where(note_annotations: { predicate: ['created', 'modified'] }) .order('note_annotations.value ASC') change_notes.group_by(&:owner).each do |_owner, notes| # slow for big collections notes.each_with_index do |note, i| note.update_column(:position, i.succ) end end end desc 'adds explicit notes positioning numbers to other note types' task :add_note_positions => :environment do note_types = Iqvoc::Concept.note_classes - [Iqvoc.change_note_class] note_types.each do |klass| puts "Migrating positions for #{klass}" notes = klass.where(position: nil).order(:id) notes.group_by(&:owner).each do |_owner, notes_for_owner| # slow for big collections notes_for_owner.each_with_index do |note, i| note.update_column(:position, i.succ) end end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
iqvoc-4.14.5 | lib/tasks/cleanup.rake |
iqvoc-4.14.4 | lib/tasks/cleanup.rake |
iqvoc-4.13.2 | lib/tasks/cleanup.rake |
iqvoc-4.13.0 | lib/tasks/cleanup.rake |