1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-08-02 20:15:22 +02:00

Make transaction enrichment opt-in for all users (#1552)
Some checks failed
Publish Docker image / ci (push) Has been cancelled
Publish Docker image / Build docker image (push) Has been cancelled

This commit is contained in:
Zach Gollwitzer 2024-12-17 09:58:08 -05:00 committed by GitHub
parent ba878c3d8b
commit 68617514b0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 46 additions and 35 deletions

View file

@ -26,10 +26,6 @@ class Settings::HostingsController < SettingsController
Setting.synth_api_key = hosting_params[:synth_api_key]
end
if hosting_params.key?(:data_enrichment_enabled)
Setting.data_enrichment_enabled = hosting_params[:data_enrichment_enabled]
end
redirect_to settings_hosting_path, notice: t(".success")
rescue ActiveRecord::RecordInvalid => error
flash.now[:alert] = t(".failure")
@ -38,7 +34,7 @@ class Settings::HostingsController < SettingsController
private
def hosting_params
params.require(:setting).permit(:render_deploy_hook, :upgrades_setting, :require_invite_for_signup, :synth_api_key, :data_enrichment_enabled)
params.require(:setting).permit(:render_deploy_hook, :upgrades_setting, :require_invite_for_signup, :synth_api_key)
end
def raise_if_not_self_hosted

View file

@ -41,7 +41,7 @@ class UsersController < ApplicationController
def user_params
params.require(:user).permit(
:first_name, :last_name, :profile_image, :redirect_to, :delete_profile_image, :onboarded_at,
family_attributes: [ :name, :currency, :country, :locale, :date_format, :timezone, :id ]
family_attributes: [ :name, :currency, :country, :locale, :date_format, :timezone, :id, :data_enrichment_enabled ]
)
end

View file

@ -11,7 +11,7 @@ class Account::Syncer
update_account_info(balances, holdings) unless account.plaid_account_id.present?
convert_records_to_family_currency(balances, holdings) unless account.currency == account.family.currency
if Setting.data_enrichment_enabled || Rails.configuration.app_mode.managed?
if account.family.data_enrichment_enabled?
account.enrich_data_later
else
Rails.logger.info("Data enrichment is disabled, skipping enrichment for account #{account.id}")

View file

@ -17,10 +17,6 @@ class Setting < RailsSettings::Base
default: ENV.fetch("UPGRADES_TARGET", "release"),
validates: { inclusion: { in: %w[release commit] } }
field :data_enrichment_enabled,
type: :boolean,
default: false
field :synth_api_key, type: :string, default: ENV["SYNTH_API_KEY"]
field :require_invite_for_signup, type: :boolean, default: false

View file

@ -1,18 +0,0 @@
<div class="space-y-4">
<div class="flex items-center justify-between">
<div class="space-y-1">
<p class="text-sm"><%= t(".title") %></p>
<p class="text-gray-500 text-sm"><%= t(".description") %></p>
</div>
<%= styled_form_with model: Setting.new,
url: settings_hosting_path,
method: :patch,
data: { controller: "auto-submit-form", "auto-submit-form-trigger-event-value": "blur" } do |form| %>
<div class="relative inline-block select-none">
<%= form.check_box :data_enrichment_enabled, class: "sr-only peer", "data-auto-submit-form-target": "auto", "data-autosubmit-trigger-event": "input" %>
<%= form.label :data_enrichment_enabled, "&nbsp;".html_safe, class: "maybe-switch" %>
</div>
<% end %>
</div>
</div>

View file

@ -10,7 +10,6 @@
<%= render "settings/hostings/upgrade_settings" %>
<%= render "settings/hostings/provider_settings" %>
<%= render "settings/hostings/synth_settings" %>
<%= render "settings/hostings/data_enrichment_settings" %>
</div>
<% end %>

View file

@ -0,0 +1,24 @@
<%# locals: (user:) %>
<div class="space-y-4">
<div class="flex items-center justify-between">
<div class="space-y-1">
<p class="text-sm"><%= t(".title") %></p>
<p class="text-gray-500 text-sm"><%= t(".description") %></p>
<% if self_hosted? %>
<p class="text-xs italic text-gray-500"><%= t(".self_host_disclaimer") %></p>
<% end %>
</div>
<%= styled_form_with model: user,
data: { controller: "auto-submit-form", "auto-submit-form-trigger-event-value": "blur" } do |form| %>
<div class="relative inline-block select-none">
<%= form.hidden_field :redirect_to, value: "preferences" %>
<%= form.fields_for :family do |family_form| %>
<%= family_form.check_box :data_enrichment_enabled, class: "sr-only peer", "data-auto-submit-form-target": "auto", "data-autosubmit-trigger-event": "input" %>
<%= family_form.label :data_enrichment_enabled, "&nbsp;".html_safe, class: "maybe-switch" %>
<% end %>
</div>
<% end %>
</div>
</div>

View file

@ -40,6 +40,11 @@
<% end %>
</div>
<% end %>
<%= settings_section title: t(".data"), subtitle: t(".data_subtitle") do %>
<%= render "settings/preferences/data_enrichment_settings", user: @user %>
<% end %>
<%= settings_section title: t(".theme_title"), subtitle: t(".theme_subtitle") do %>
<div>
<%= styled_form_with model: @user, class: "flex justify-between items-center" do |form| %>