mirror of
https://github.com/we-promise/sure.git
synced 2026-06-08 20:29:05 +00:00
Split family and Plaid item syncs into multiple jobs (#1799)
* Split family and Plaid item syncs into multiple jobs * fix test expectations
This commit is contained in:
@@ -37,16 +37,12 @@ class Family < ApplicationRecord
|
||||
update!(last_synced_at: Time.current)
|
||||
|
||||
accounts.manual.each do |account|
|
||||
account.sync_data(start_date: start_date)
|
||||
account.sync_later(start_date: start_date)
|
||||
end
|
||||
|
||||
plaid_data = []
|
||||
|
||||
plaid_items.each do |plaid_item|
|
||||
plaid_data << plaid_item.sync_data(start_date: start_date)
|
||||
plaid_item.sync_later(start_date: start_date)
|
||||
end
|
||||
|
||||
plaid_data
|
||||
end
|
||||
|
||||
def post_sync
|
||||
|
||||
@@ -41,7 +41,7 @@ class PlaidItem < ApplicationRecord
|
||||
plaid_data = fetch_and_load_plaid_data
|
||||
|
||||
accounts.each do |account|
|
||||
account.sync_data(start_date: start_date)
|
||||
account.sync_later(start_date: start_date)
|
||||
end
|
||||
|
||||
plaid_data
|
||||
|
||||
@@ -16,11 +16,11 @@ class FamilyTest < ActiveSupport::TestCase
|
||||
manual_accounts_count = @syncable.accounts.manual.count
|
||||
items_count = @syncable.plaid_items.count
|
||||
|
||||
Account.any_instance.expects(:sync_data)
|
||||
Account.any_instance.expects(:sync_later)
|
||||
.with(start_date: nil)
|
||||
.times(manual_accounts_count)
|
||||
|
||||
PlaidItem.any_instance.expects(:sync_data)
|
||||
PlaidItem.any_instance.expects(:sync_later)
|
||||
.with(start_date: nil)
|
||||
.times(items_count)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user