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

30 day syncs by default

This commit is contained in:
Zach Gollwitzer 2025-05-12 15:01:39 -04:00
parent 6a1d625a4f
commit efea7bfc01
4 changed files with 23 additions and 25 deletions

View file

@ -10,7 +10,7 @@ module Syncable
end end
def sync_later(parent_sync: nil, window_start_date: nil, window_end_date: nil) def sync_later(parent_sync: nil, window_start_date: nil, window_end_date: nil)
new_sync = syncs.create!(parent: parent_sync, window_start_date: window_start_date, window_end_date: window_end_date) new_sync = syncs.create_with_defaults!(parent: parent_sync)
SyncJob.perform_later(new_sync) SyncJob.perform_later(new_sync)
end end

View file

@ -31,7 +31,14 @@ class Sync < ApplicationRecord
end end
end end
def perform(window_start_date: nil, window_end_date: nil) class << self
# By default, we sync the "visible" window of data (user sees 30 day graphs by default)
def create_with_defaults!(parent: nil)
create!(parent: parent, window_start_date: 30.days.ago.to_date)
end
end
def perform
start! start!
begin begin

View file

@ -2,15 +2,17 @@
<h1 class="text-xl"><%= t(".accounts") %></h1> <h1 class="text-xl"><%= t(".accounts") %></h1>
<div class="flex items-center gap-5"> <div class="flex items-center gap-5">
<div class="flex items-center gap-2"> <div class="flex items-center gap-2">
<%= render ButtonComponent.new( <% if Rails.env.development? %>
text: "Sync all", <%= render ButtonComponent.new(
href: sync_all_accounts_path, text: "Sync all",
method: :post, href: sync_all_accounts_path,
variant: "outline", method: :post,
disabled: Current.family.syncing?, variant: "outline",
icon: "refresh-cw", disabled: Current.family.syncing?,
class: "" icon: "refresh-cw",
) %> class: ""
) %>
<% end %>
<%= render LinkComponent.new( <%= render LinkComponent.new(
text: "New account", text: "New account",

View file

@ -20,26 +20,15 @@
<% end %> <% end %>
<div class="flex items-center gap-1 ml-auto"> <div class="flex items-center gap-1 ml-auto">
<% if account.plaid_account_id.present? %> <% if Rails.env.development? %>
<% if Rails.env.development? %> <%= icon(
<%= icon(
"refresh-cw", "refresh-cw",
as_button: true, as_button: true,
size: "sm", 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?, disabled: account.syncing?,
frame: :_top frame: :_top
) %> ) %>
<% end %>
<% else %>
<%= icon(
"refresh-cw",
as_button: true,
size: "sm",
href: sync_account_path(account),
disabled: account.syncing?,
frame: :_top
) %>
<% end %> <% end %>
<%= render "accounts/show/menu", account: account %> <%= render "accounts/show/menu", account: account %>