Sha256: f1854750437bc24766522e05696b3f55c8264dd00c735fd1730013dffbda32d8

Contents?: true

Size: 1.08 KB

Versions: 28

Compression:

Stored size: 1.08 KB

Contents

class AwesomeTranslations::CleanUpsController < AwesomeTranslations::ApplicationController
  def new
  end

  def create
    ids = []
    params[:c].each do |translation_value_id, check_value|
      ids << translation_value_id.to_i if check_value == "1"
    end

    translation_values = AwesomeTranslations::CacheDatabaseGenerator::TranslationValue
      .where(id: ids)

    translation_values.each do |translation_value|
      AwesomeTranslations::TranslationMigrator.new(translation_value: translation_value).execute
      translation_value.destroy!
    end

    redirect_to [:new, :clean_up]
  end

private

  helper_method :translations_to_clean_up
  def translations_to_clean_up
    @translations_to_migrate ||= AwesomeTranslations::CacheDatabaseGenerator::TranslationValue
      .joins(:translation_key)
      .includes(:translation_key)
      .joins("LEFT JOIN handler_translations ON handler_translations.translation_key_id = translation_keys.id")
      .where("handler_translations.id IS NULL")
      .where("translation_values.file_path LIKE '%/config/locales/awesome_translations/%'")
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
awesome_translations-0.0.53 app/controllers/awesome_translations/clean_ups_controller.rb
awesome_translations-0.0.52 app/controllers/awesome_translations/clean_ups_controller.rb
awesome_translations-0.0.51 app/controllers/awesome_translations/clean_ups_controller.rb
awesome_translations-0.0.50 app/controllers/awesome_translations/clean_ups_controller.rb
awesome_translations-0.0.49 app/controllers/awesome_translations/clean_ups_controller.rb
awesome_translations-0.0.48 app/controllers/awesome_translations/clean_ups_controller.rb
awesome_translations-0.0.47 app/controllers/awesome_translations/clean_ups_controller.rb
awesome_translations-0.0.46 app/controllers/awesome_translations/clean_ups_controller.rb
awesome_translations-0.0.45 app/controllers/awesome_translations/clean_ups_controller.rb
awesome_translations-0.0.44 app/controllers/awesome_translations/clean_ups_controller.rb
awesome_translations-0.0.43 app/controllers/awesome_translations/clean_ups_controller.rb
awesome_translations-0.0.42 app/controllers/awesome_translations/clean_ups_controller.rb
awesome_translations-0.0.41 app/controllers/awesome_translations/clean_ups_controller.rb
awesome_translations-0.0.40 app/controllers/awesome_translations/clean_ups_controller.rb
awesome_translations-0.0.39 app/controllers/awesome_translations/clean_ups_controller.rb
awesome_translations-0.0.38 app/controllers/awesome_translations/clean_ups_controller.rb
awesome_translations-0.0.37 app/controllers/awesome_translations/clean_ups_controller.rb
awesome_translations-0.0.36 app/controllers/awesome_translations/clean_ups_controller.rb
awesome_translations-0.0.35 app/controllers/awesome_translations/clean_ups_controller.rb
awesome_translations-0.0.34 app/controllers/awesome_translations/clean_ups_controller.rb