Conversation
mrcasals
left a comment
There was a problem hiding this comment.
Nice! I left a few suggestions
| desc "Rebuild the search index" | ||
| task rebuild_search: :environment do | ||
| Decidim::SearchableResource.destroy_all | ||
| Decidim::Searchable.searchable_resources.pluck(0).each do |resource| |
There was a problem hiding this comment.
| Decidim::Searchable.searchable_resources.pluck(0).each do |resource| | |
| Decidim::Searchable.searchable_resources.keys.each do |resource| |
docs/advanced/fixing_locales.md
Outdated
| bundle exec rake decidim:locales:sync_all | ||
| ``` | ||
|
|
||
| Run this task if you want have changed your `config/initializers/decidim.rb` `available_locales` or `default_locale` and you want to modify all the organizations so they have the same settings. |
There was a problem hiding this comment.
| Run this task if you want have changed your `config/initializers/decidim.rb` `available_locales` or `default_locale` and you want to modify all the organizations so they have the same settings. | |
| Run this task if you want to have changed `available_locales` or `default_locale` in your `config/initializers/decidim.rb` and you want to modify all the organizations so they have the same settings. |
There was a problem hiding this comment.
In here I've rephrase it.
| task rebuild_search: :environment do | ||
| Decidim::SearchableResource.destroy_all | ||
| Decidim::Searchable.searchable_resources.keys.each do |resource| | ||
| resource.constantize.all.each(&:try_update_index_for_search_resource) |
There was a problem hiding this comment.
| resource.constantize.all.each(&:try_update_index_for_search_resource) | |
| resource.constantize.find_each(&:try_update_index_for_search_resource) |
This is more performant, memory-wise, as it loads the resources in chunks instead of all of them at the same time.
There was a problem hiding this comment.
Also, the Decidim::Searchable.searchable_resources has the classes as values. I'm not sure if you're constantizing for some specific reason, but the whole block could be changed to this:
Decidim::Searchable.searchable_resources.values.each do |searchable_klass|
searchable_klass.find_each(&:try_update_index_for_search_resource)
endThere was a problem hiding this comment.
oh, I don't even remember. I guess I saw the key and my brain executed a return!
Thanks for your insights! I'll make the changes!
There was a problem hiding this comment.
If you prefer, you can just ignore these lastc hangees and keep only the find_each suggestion 😄
There was a problem hiding this comment.
No, I like it. I'll continue in the afternoon, I have a busy morning.
Thinking out loud, we could add a task to add or remove a language from an organization and perform all the associated task for that organization.
|
@mrcasals in the end, I've refactored a little to show more information when performing the task. Also changed some docs that where wrong. The result of both commands looks like this: |
|
@microstudi nice!! Good job! I've restarted a teest run that failede, looked like some Ruby setup problem |
Leusev
left a comment
There was a problem hiding this comment.
Looks fantastic for me @microstudi
Liked the idea about what you pointed out about to add some new tasks in order to add or remove a new language, since it is not a rare thing and it has also been requested on some occasion...
Thanks for your job 😄
* Add a task to fix locale issues * spell fixes * print more information on the console and optimize code
* Remove Markdown doc * Add documentation with Antora (AsciiDoc format - .adoc) Adds sections: * configure * customize * develop * install * services Also adds: * a README explaining the relationship with the documentation repository available in https://github.com/decidim/documentation * antora metadata file so we can build these sections in the same website * Fix Antora name for docs * Rename advanced pages to Concerns * Add Authorizations customize from module's README * Move 'add_authorizable_action' to 'permissions' * Move 'adding_fixtures_aka_dummy_content' to 'components' * Move 'how_to_create_a_module' to 'components' * Remove 'upgrading', now it's in 'update' * Install guide: fix error in 'whatever' gem (it's 'whenever') * Install guide: fix error in RAILS_ENV order in commands * Install guide: fix command for open_data export * Install guide: fix link to Contribution guide * Develop guide: add example apps * Architecture docs Add first version of c4model diagrams with PlantUML * https://c4model.com/ * https://plantuml.com/ * https://github.com/RicardoNiepel/C4-PlantUML * Add some explanation of modules types (with Components link) * Configure: ENV VARS and Initializer This moves ENV VARS configuration docs to its own page. We also create a new page for explaining Decidim's initializer settings (config/initializer/decidim.rb). For the moment is mostly a copy paste with nice formating, but the idea is to expand it. * Sync "Make maps actually configurable" by @ahukkanen Extracted from #6340 * Sync "Templates module" by @verarojman Extracted from #6247 * Sync "Configure Decidim Bulletin Board" by @leio10 Extracted from #6420 * Sync "Add a task to fix locale issues" by @microstudi Extracted from #6510 * Update versions in SECURITY.adoc * Convert CONTRIBUTING.md to AsciiDoc * Convert README.md to AsciiDoc * Clarify CONTRIBUTING and links to docs site * Remove Markdown linter CI * Sync "Update documentation for `decidim` OAuth social provider" by @tramuntanal Extracted from #6607 * Sync "Generate changelog entries" by @tramuntanal Extracted from #6794 * Fix link in oauth.adoc * Sync "Improve moderation panel" by @beagleknight Extracted from #6677 * Removes trailing whitespaces Co-authored-by: Oliver Valls <199462+tramuntanal@users.noreply.github.com>


🎩 What? Why?
In certain cases is necessary to manipulate locales of an organization through the database. This adds a new task namespace and some commands to solve common issues.
It also provides a new documentation file explaining the usage.
📋 Subtasks