Sha256: faced444be6884b217ce1ae50f10c4662f5fe6b1192ccc5b416dcf816fae6b9a

Contents?: true

Size: 899 Bytes

Versions: 22

Compression:

Stored size: 899 Bytes

Contents

# desc "Explaining what the task does"
# task :klastera do
#   # Task goes here
# end


namespace :klastera do
  namespace :seed do
    
    desc "Move cluster_id to cluster_entities"
    task :cluster_entities, [:entity] => :environment do |task,args|
      begin
        klass = args.entity.constantize
        ActiveRecord::Base.transaction do
          klass.where.not(cluster_id: nil).each do |entity|
            if entity.cluster.blank?
              puts "Cluster ID #{entity.cluster_id} was not found!"
              puts "skip..."
              next
            end
            Klastera::ClusterEntity.create(entity: entity, cluster: entity.cluster)
          end
        end
      rescue NameError => ne
        puts "NameError Exception: #{ne}"
      rescue ActiveRecord::StatementInvalid => asi
        puts "ActiveRecord::StatementInvalid Exception #{asi}"
      end
    end

  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
klastera-1.5.4 lib/tasks/klastera_tasks.rake
klastera-1.5.2.4 lib/tasks/klastera_tasks.rake
klastera-1.4.4.5 lib/tasks/klastera_tasks.rake
klastera-1.5.1.0 lib/tasks/klastera_tasks.rake
klastera-1.5 lib/tasks/klastera_tasks.rake
klastera-1.4.4.3.1 lib/tasks/klastera_tasks.rake
klastera-1.4.4.4 lib/tasks/klastera_tasks.rake
klastera-1.4.4.3 lib/tasks/klastera_tasks.rake
klastera-1.4.4.2 lib/tasks/klastera_tasks.rake
klastera-1.4.4.1 lib/tasks/klastera_tasks.rake
klastera-1.4.4 lib/tasks/klastera_tasks.rake
klastera-1.4.3 lib/tasks/klastera_tasks.rake
klastera-1.4.2 lib/tasks/klastera_tasks.rake
klastera-1.4.1 lib/tasks/klastera_tasks.rake
klastera-1.4.0.3 lib/tasks/klastera_tasks.rake
klastera-1.4.0.2 lib/tasks/klastera_tasks.rake
klastera-1.4.0.1 lib/tasks/klastera_tasks.rake
klastera-1.4 lib/tasks/klastera_tasks.rake
klastera-1.3.3.1 lib/tasks/klastera_tasks.rake
klastera-1.3.2 lib/tasks/klastera_tasks.rake