feat: Add parameters in setting to enable/disable auto-sync and define timing

This commit is contained in:
Alessio Cappa
2026-01-11 19:42:35 +01:00
parent 19da11ed4e
commit 5b74e8d90b
3 changed files with 47 additions and 1 deletions

View File

@@ -62,6 +62,16 @@ class Settings::HostingsController < ApplicationController
Setting.syncs_include_pending = hosting_params[:syncs_include_pending] == "1"
end
if hosting_params.key?(:auto_sync_enabled)
Setting.auto_sync_enabled = hosting_params[:auto_sync_enabled] == "1"
AutoSyncScheduler.sync!
end
if hosting_params.key?(:auto_sync_time)
Setting.auto_sync_time = hosting_params[:auto_sync_time]
AutoSyncScheduler.sync!
end
if hosting_params.key?(:openai_access_token)
token_param = hosting_params[:openai_access_token].to_s.strip
# Ignore blanks and redaction placeholders to prevent accidental overwrite
@@ -103,7 +113,7 @@ class Settings::HostingsController < ApplicationController
private
def hosting_params
params.require(:setting).permit(:onboarding_state, :require_email_confirmation, :brand_fetch_client_id, :twelve_data_api_key, :openai_access_token, :openai_uri_base, :openai_model, :openai_json_mode, :exchange_rate_provider, :securities_provider, :syncs_include_pending)
params.require(:setting).permit(:onboarding_state, :require_email_confirmation, :brand_fetch_client_id, :twelve_data_api_key, :openai_access_token, :openai_uri_base, :openai_model, :openai_json_mode, :exchange_rate_provider, :securities_provider, :syncs_include_pending, :auto_sync_enabled, :auto_sync_time)
end
def ensure_admin