Sha256: 04451743a94e9dfdb7723090eac9863891ff7c0cd44f97fa1b9659e070c8fa57
Contents?: true
Size: 1.36 KB
Versions: 52
Compression:
Stored size: 1.36 KB
Contents
# frozen_string_literal: true namespace :decidim do namespace :locales do desc "Ensures locales in organizations are in sync with Decidim initializer" task sync_all: :environment do allowed_locales = Decidim.available_locales.map(&:to_s) Decidim::Organization.find_each do |organization| print "#{organization.name} uses #{organization.available_locales} with [#{organization.default_locale}] as default" orphan = (organization.available_locales - allowed_locales) organization.available_locales = organization.available_locales - orphan default = organization.default_locale organization.default_locale = organization.available_locales.first unless organization.available_locales.include? default if default != organization.default_locale || orphan.present? organization.save! puts " [FIXED]" else puts " [OK]" end end end desc "Rebuild the search index" task rebuild_search: :environment do Decidim::SearchableResource.destroy_all total = Decidim::Searchable.searchable_resources.count Decidim::Searchable.searchable_resources.values.each.with_index(1) do |klass, index| print "Indexing #{index}/#{total} #{klass}" klass.find_each(&:try_update_index_for_search_resource) puts " [DONE]" end end end end
Version data entries
52 entries across 52 versions & 1 rubygems