Last active
September 26, 2016 14:09
-
-
Save serenaf/8dd2ff9d7bb94445de45a32f06f461cd to your computer and use it in GitHub Desktop.
Opt in Acquire Lite Apps
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
opt_ins = [] | |
App.find_each do |app| | |
if app.can_use_feature?(:welcome_message) && !app.can_use_feature?(:visitor_auto_messaging) && PermittedLanguage.where(app_id: app.id).count > 1 | |
opt_ins << app.id | |
end | |
end | |
opt_ins | |
app = a 6 | |
admin = app.admins.where(email: 'serena@intercom.io').first | |
feature = Feature.fetch_by_name('acquire-lite-localisation-support') | |
feature.opt_in_apps(opt_ins, admin) | |
@agerlic This query uses the index on index_permitted_languages_on_app_id_and_locale
see expplain output of local dev environment:
`1 | SIMPLE | permitted_languages | ref | index_permitted_languages_on_app_id_and_locale | index_permitted_languages_on_app_id_and_locale | 4 | const | 1 | Using index``
Moved to a rake task, see https://github.com/intercom/intercom/pull/59100/files
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
PermittedLanguage.where(app_id: app.id).count
can you check if this query uses an index ?otherwise, could we load all PermittedLanguage with one query in memory ? eg :
permittedlanguages = PermittedLanguage.all