docbrown/config/initializers/algoliasearch.rb
rhymes e588fa7ece Code cleanups (#659)
* Initial automatic cleanup with rubocop

* Fix syntax error introduced by rubocop

* Cleanup seeds file

* Cleanup lib folder

* Exclude bin folder because it contains auto generated files

* Make Rubocop a little bit more chatty

* Block length should not include comments in the count

* Cleanup config folder

* Cleanup specs

* Updated Rubocop version and generated a todo file

* Fix broken ArticlesApi spec

* Fix tests

* Restored rubocop pre-commit hook
2018-08-07 11:00:13 -04:00

25 lines
799 B
Ruby

AlgoliaSearch.configuration = {
application_id: ApplicationConfig["ALGOLIASEARCH_APPLICATION_ID"],
api_key: ApplicationConfig["ALGOLIASEARCH_API_KEY"],
}
if Rails.env.test?
::ALGOLIASEARCH_PUBLIC_SEARCH_ONLY_KEY = "test_test_test".freeze
else
# Restrict Access to private indices
params = {
restrictIndices: [
"searchables_#{Rails.env}",
"Tag_#{Rails.env}",
"ordered_articles_#{Rails.env}",
"ordered_articles_by_published_at_#{Rails.env}",
"ordered_articles_by_positive_reactions_count_#{Rails.env}",
"ordered_comments_#{Rails.env}",
].join(","),
}
secured_algolia_key = Algolia.generate_secured_api_key(
ApplicationConfig["ALGOLIASEARCH_SEARCH_ONLY_KEY"], params
)
::ALGOLIASEARCH_PUBLIC_SEARCH_ONLY_KEY = secured_algolia_key
end