module Jekyll::Algolia::Indexer
def self.update_settings
If the settingID are not matching, it means our config is different, so
preferred way of doing so.
manually altered though, and warn the user that this is not the
anything. We will still check if the remote config seem to have been
If the settingID is the same, we don't push as this won't change
settings already pushed. It will compare userData.settingID for that.
This will first compare the settings about to be pushed with the
Public: Smart update of the settings of the index
def self.update_settings current_remote_settings = remote_settings || {} remote_setting_id = current_remote_settings.dig('userData', 'settingID') settings = Configurator.settings setting_id = local_setting_id are_settings_forced = Configurator.force_settings? # The config we're about to push is the same we pushed previously. We # won't push again. if setting_id == remote_setting_id && !are_settings_forced Logger.log('I:Settings are already up to date.') # Check if remote config has been changed outside of the plugin, so we # can warn users that they should not alter their config from outside # of the plugin. current_remote_settings.delete('userData') changed_keys = Utils.diff_keys(settings, current_remote_settings) unless changed_keys.nil? warn_of_manual_dashboard_editing(changed_keys) end return end # Settings have changed, we push them settings['userData'] = { 'settingID' => setting_id, 'pluginVersion' => VERSION } Logger.log("I:Updating settings of index #{index.name}") return if Configurator.dry_run? set_settings(settings) end