1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-08-08 06:55:21 +02:00

Auto sync preference, max limit on account CSV imports

This commit is contained in:
Zach Gollwitzer 2025-05-18 14:25:38 -04:00
parent f82f77466a
commit 62160facb5
5 changed files with 18 additions and 1 deletions

View file

@ -13,6 +13,7 @@ module AutoSync
def family_needs_auto_sync?
return false unless Current.family&.accounts&.active&.any?
return false if (Current.family.last_sync_created_at&.to_date || 1.day.ago) >= Date.current
return false unless Current.family.auto_sync_on_login
Rails.logger.info "Auto-syncing family #{Current.family.id}, last sync was #{Current.family.last_sync_created_at}"

View file

@ -1,5 +1,7 @@
class AccountImport < Import
def import!
raise "Account import is limited to 50 rows" if rows.count > 50
transaction do
rows.each do |row|
mapping = mappings.account_types.find_by(key: row.entity_type)

View file

@ -0,0 +1,5 @@
class AddAutoSyncPreferenceToFamily < ActiveRecord::Migration[7.2]
def change
add_column :families, :auto_sync_on_login, :boolean, default: true, null: false
end
end

3
db/schema.rb generated
View file

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[7.2].define(version: 2025_05_16_180846) do
ActiveRecord::Schema[7.2].define(version: 2025_05_18_181619) do
# These are extensions that must be enabled in order to support this database
enable_extension "pgcrypto"
enable_extension "plpgsql"
@ -227,6 +227,7 @@ ActiveRecord::Schema[7.2].define(version: 2025_05_16_180846) do
t.string "timezone"
t.boolean "data_enrichment_enabled", default: false
t.boolean "early_access", default: false
t.boolean "auto_sync_on_login", default: true, null: false
end
create_table "holdings", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|

View file

@ -38,4 +38,12 @@ class AutoSyncTest < ActionDispatch::IntegrationTest
get root_path
end
end
test "does not auto-sync if preference is disabled" do
@family.update!(auto_sync_on_login: false)
assert_no_difference "Sync.count" do
get root_path
end
end
end