Skip to content

armgit / maybe

Public Imported from GitHub
0

The personal finance app for everyone

Only run Plaid syncs via webhook after initial sync

Zach Gollwitzer9e6e4b1ce693
diff --git a/app/models/family.rb b/app/models/family.rb
index f565d54d..a3a73eec 100644
--- a/app/models/family.rb
+++ b/app/models/family.rb
@@ -74,11 +74,6 @@ class Family < ApplicationRecord
account.sync_later(start_date: start_date, parent_sync: sync)
end
- Rails.logger.info("Syncing plaid items for family #{id}")
- plaid_items.each do |plaid_item|
- plaid_item.sync_later(start_date: start_date, parent_sync: sync)
- end
-
Rails.logger.info("Applying rules for family #{id}")
rules.each do |rule|
rule.apply_later
diff --git a/app/views/accounts/index.html.erb b/app/views/accounts/index.html.erb
index 4893e44c..b4c78332 100644
--- a/app/views/accounts/index.html.erb
+++ b/app/views/accounts/index.html.erb
@@ -2,15 +2,16 @@
<h1 class="text-xl"><%= t(".accounts") %></h1>
<div class="flex items-center gap-5">
<div class="flex items-center gap-2">
- <%= render ButtonComponent.new(
- text: "Sync all",
- href: sync_all_accounts_path,
- method: :post,
- variant: "outline",
- disabled: Current.family.syncing?,
- icon: "refresh-cw",
- class: ""
- ) %>
+ <% if Rails.env.development? %>
+ <%= render ButtonComponent.new(
+ text: "Sync all",
+ href: sync_all_accounts_path,
+ method: :post,
+ variant: "outline",
+ disabled: Current.family.syncing?,
+ icon: "refresh-cw",
+ ) %>
+ <% end %>
<%= render LinkComponent.new(
text: "New account",
diff --git a/app/views/accounts/show/_header.html.erb b/app/views/accounts/show/_header.html.erb
index 4c60e832..b64408ce 100644
--- a/app/views/accounts/show/_header.html.erb
+++ b/app/views/accounts/show/_header.html.erb
@@ -20,26 +20,15 @@
<% end %>
<div class="flex items-center gap-1 ml-auto">
- <% if account.plaid_account_id.present? %>
- <% if Rails.env.development? %>
- <%= icon(
+ <% if Rails.env.development? %>
+ <%= icon(
"refresh-cw",
as_button: true,
size: "sm",
- href: sync_plaid_item_path(account.plaid_account.plaid_item),
+ href: account.linked? ? sync_plaid_item_path(account.plaid_account.plaid_item) : sync_account_path(account),
disabled: account.syncing?,
frame: :_top
) %>
- <% end %>
- <% else %>
- <%= icon(
- "refresh-cw",
- as_button: true,
- size: "sm",
- href: sync_account_path(account),
- disabled: account.syncing?,
- frame: :_top
- ) %>
<% end %>
<%= render "accounts/show/menu", account: account %>
diff --git a/app/views/plaid_items/_plaid_item.html.erb b/app/views/plaid_items/_plaid_item.html.erb
index 7c3dc8b2..61dea7dc 100644
--- a/app/views/plaid_items/_plaid_item.html.erb
+++ b/app/views/plaid_items/_plaid_item.html.erb
@@ -92,7 +92,7 @@
</div>
</div>
<% end %>
- <% else %>
+ <% elsif Rails.env.development? %>
<%= icon(
"refresh-cw",
as_button: true,
diff --git a/test/models/family_test.rb b/test/models/family_test.rb
index 7223e64b..24876a77 100644
--- a/test/models/family_test.rb
+++ b/test/models/family_test.rb
@@ -20,10 +20,6 @@ class FamilyTest < ActiveSupport::TestCase
.with(start_date: nil, parent_sync: family_sync)
.times(manual_accounts_count)
- PlaidItem.any_instance.expects(:sync_later)
- .with(start_date: nil, parent_sync: family_sync)
- .times(items_count)
-
@syncable.sync_data(family_sync, start_date: family_sync.start_date)
end
end