Sha256: 75210c529e46c24281caeb200faf83fe271ecaab8151712e975651c68d6dde54

Contents?: true

Size: 1.55 KB

Versions: 2

Compression:

Stored size: 1.55 KB

Contents

namespace :georgia do

  namespace :migrate do

    desc "Saves ancestry from legacy parent_id"
    task ancestry: :environment do

      Georgia::Page.find_each do |page|
        if parent = page.attributes['parent_id']
          begin
            page.parent = Georgia::Page.find(parent)
            page.save!
          rescue ActiveRecord::RecordNotFound
            puts 'Page not found'
          end
        end
      end

    end

    desc "Saves keywords to tags list"
    task tags: :environment do

      Georgia::Content.find_each do |content|
        content.keyword_list = content.keywords
        content.save
      end

    end
  end

  desc "Purge assets that don't have an existing file in the cloud"
  task purge: :environment do
    count = 0
    Ckeditor::Asset.find_each do |asset|
      begin
        if !asset.data.file.exists?
          asset.destroy
          count += 1
        end
      end
    end
    puts "#{count} assets purged."
  end

  namespace :messages do

    desc "Send to Akismet all unverified messages"
    task verify: :environment do
      puts "Check for spam. Currently have #{Georgia::Message.spam.count} spam and #{Georgia::Message.ham.count} ham messages."
      puts "Checking #{Georgia::Message.where(verified_at: nil).count} unverified messages."
      Georgia::Message.where(verified_at: nil).find_each do |message|
        message.update_attributes(spam: message.spam?, verified_at: Time.zone.now)
      end
      puts "Check completed. #{Georgia::Message.spam.count} spam. #{Georgia::Message.ham.count} ham."
    end

  end


end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
georgia-0.7.1 lib/tasks/georgia.rake
georgia-0.7.0 lib/tasks/georgia.rake