Sha256: 537f41cd46f6242b9302ebba3663965a799a38880f09afeed4c7e88dd8558d5a

Contents?: true

Size: 1.31 KB

Versions: 1

Compression:

Stored size: 1.31 KB

Contents

include Rake::DSL if defined?(Rake::DSL)
require 'progressbar'
namespace :pose do

  namespace :index do

    desc "Cleans out unused data from the search index."
    task :vacuum => :environment do |t, args|
      puts "Cleaning Pose search index ...\n\n"
      progress_bar = ProgressBar.new '  assignments', PoseAssignment.count
      PoseAssignment.cleanup_orphaned_pose_assignments progress_bar
      progress_bar.finish

      progress_bar = ProgressBar.new '  words', PoseWord.count
      PoseWord.remove_unused_words progress_bar
      progress_bar.finish

      puts "\nPose search index cleanup complete.\n\n"
    end

    desc "Removes the search index for all instances of the given classes."
    task :remove, [:class_name] => :environment do |t, args|
      clazz = Kernel.const_get args.class_name
      PoseAssignment.cleanup_class_index clazz
      puts "Search index for class #{clazz.name} deleted.\n\n"
    end

    desc "Deletes and recreates the search index for all instances of the given class."
    task :reindex_all, [:class_name] => [:environment] do |t, args|
      clazz = args.class_name.constantize
      progress_bar = ProgressBar.new "  reindexing", clazz.count
      clazz.find_each do |instance|
        instance.update_pose_words
        progress_bar.inc
      end
      progress_bar.finish
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pose-1.3.2 lib/tasks/pose_tasks.rake