1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-19 13:19:39 +02:00

Add post-sync UI stream updates (#1482)
Some checks failed
Publish Docker image / ci (push) Has been cancelled
Publish Docker image / Build docker image (push) Has been cancelled

* Add post-sync UI stream updates

* Fix stream channel id
This commit is contained in:
Zach Gollwitzer 2024-11-20 16:46:06 -05:00 committed by GitHub
parent e641cfccd4
commit 6996a225ba
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 35 additions and 8 deletions

1
.gitignore vendored
View file

@ -6,6 +6,7 @@
# Ignore bundler config. # Ignore bundler config.
/.bundle /.bundle
/vendor/bundle
# Ignore all environment files (except templates). # Ignore all environment files (except templates).
/.env* /.env*

View file

@ -1,3 +1,3 @@
web: ${DEBUG:+rdbg -O -n -c --} bin/rails server -b 0.0.0.0 web: bundle exec ${DEBUG:+rdbg -O -n -c --} bin/rails server -b 0.0.0.0
css: bin/rails tailwindcss:watch css: bundle exec bin/rails tailwindcss:watch
worker: bundle exec good_job start worker: bundle exec good_job start

View file

@ -99,6 +99,10 @@ class Account < ApplicationRecord
Holding::Syncer.new(self, start_date: start_date).run Holding::Syncer.new(self, start_date: start_date).run
end end
def post_sync
accountable.post_sync
end
def original_balance def original_balance
balance_amount = balances.chronological.first&.balance || balance balance_amount = balances.chronological.first&.balance || balance
Money.new(balance_amount, currency) Money.new(balance_amount, currency)

View file

@ -46,6 +46,6 @@ class Account::Balance::Syncer
end end
def is_partial_sync? def is_partial_sync?
sync_start_date == provided_start_date && sync_start_date < Date.current sync_start_date == provided_start_date
end end
end end

View file

@ -33,4 +33,15 @@ module Accountable
rescue Money::ConversionError rescue Money::ConversionError
TimeSeries.new([]) TimeSeries.new([])
end end
def post_sync
broadcast_remove_to(account, target: "syncing-notification")
broadcast_replace_to(
account,
target: "chart_account_#{account.id}",
partial: "accounts/show/chart",
locals: { account: account }
)
end
end end

View file

@ -54,4 +54,15 @@ class Investment < ApplicationRecord
def icon def icon
"line-chart" "line-chart"
end end
def post_sync
broadcast_remove_to(account, target: "syncing-notification")
broadcast_replace_to(
account,
target: "chart_account_#{account.id}",
partial: account.plaid_account_id.present? ? "investments/chart" : "accounts/show/chart",
locals: { account: account }
)
end
end end

View file

@ -1,11 +1,11 @@
<%# locals: (account:, title: nil, tooltip: nil) %> <%# locals: (account:, title: nil, tooltip: nil, **args) %>
<% period = Period.from_param(params[:period]) %> <% period = Period.from_param(params[:period]) %>
<% series = account.series(period: period) %> <% series = account.series(period: period) %>
<% trend = series.trend %> <% trend = series.trend %>
<% default_value_title = account.asset? ? t(".balance") : t(".owed") %> <% default_value_title = account.asset? ? t(".balance") : t(".owed") %>
<div class="bg-white shadow-xs rounded-xl border border-alpha-black-25 rounded-lg"> <div id="<%= dom_id(account, :chart) %>" class="bg-white shadow-xs rounded-xl border border-alpha-black-25 rounded-lg">
<div class="p-4 flex justify-between"> <div class="p-4 flex justify-between">
<div class="space-y-2"> <div class="space-y-2">
<div class="flex items-center gap-1"> <div class="flex items-center gap-1">

View file

@ -21,7 +21,7 @@
<div class="flex items-center gap-3 ml-auto"> <div class="flex items-center gap-3 ml-auto">
<% unless account.plaid_account_id.present? %> <% unless account.plaid_account_id.present? %>
<%= button_to sync_account_path(account), disabled: account.syncing?, class: "flex items-center gap-2", title: "Sync Account" do %> <%= button_to sync_account_path(account), disabled: account.syncing?, data: { turbo: false }, class: "flex items-center gap-2", title: "Sync Account" do %>
<%= lucide_icon "refresh-cw", class: "w-4 h-4 text-gray-500 hover:text-gray-400" %> <%= lucide_icon "refresh-cw", class: "w-4 h-4 text-gray-500 hover:text-gray-400" %>
<% end %> <% end %>
<% end %> <% end %>

View file

@ -1,10 +1,10 @@
<%# locals: (account:) %> <%# locals: (account:, **args) %>
<% period = Period.from_param(params[:period]) %> <% period = Period.from_param(params[:period]) %>
<% series = account.series(period: period) %> <% series = account.series(period: period) %>
<% trend = series.trend %> <% trend = series.trend %>
<div class="bg-white shadow-xs rounded-xl border border-alpha-black-25 rounded-lg"> <div id="<%= dom_id(account, :chart) %>" class="bg-white shadow-xs rounded-xl border border-alpha-black-25 rounded-lg">
<div class="p-4 flex justify-between"> <div class="p-4 flex justify-between">
<div class="space-y-2"> <div class="space-y-2">
<div class="flex items-center gap-1"> <div class="flex items-center gap-1">