mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-02 20:15:22 +02:00
Improved UI warning states for holdings with missing data (#1098)
* Fix security price issue flow * Fix tooltip positioning and add tooltip for missing holding data * Fix tooltip controller error with stale arrow target * Lint fixes
This commit is contained in:
parent
4527482aa2
commit
1b6ce6af45
16 changed files with 141 additions and 75 deletions
|
@ -75,9 +75,11 @@ class Account < ApplicationRecord
|
|||
end
|
||||
end
|
||||
|
||||
def alert
|
||||
latest_sync = syncs.latest
|
||||
[ latest_sync&.error, *latest_sync&.warnings ].compact.first
|
||||
def owns_ticker?(ticker)
|
||||
security_id = Security.find_by(ticker: ticker)&.id
|
||||
entries.account_trades
|
||||
.joins("JOIN account_trades ON account_entries.entryable_id = account_trades.id")
|
||||
.where(account_trades: { security_id: security_id }).any?
|
||||
end
|
||||
|
||||
def favorable_direction
|
||||
|
|
|
@ -25,6 +25,8 @@ class Account::Sync < ApplicationRecord
|
|||
rescue StandardError => error
|
||||
account.observe_unknown_issue(error)
|
||||
fail! error
|
||||
|
||||
raise error if Rails.env.development?
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
class Issue::PricesMissing < Issue
|
||||
store_accessor :data, :missing_prices
|
||||
|
||||
after_initialize :initialize_missing_prices
|
||||
|
||||
validates :missing_prices, presence: true
|
||||
|
||||
def append_missing_price(ticker, date)
|
||||
|
@ -10,7 +12,10 @@ class Issue::PricesMissing < Issue
|
|||
|
||||
def stale?
|
||||
stale = true
|
||||
|
||||
missing_prices.each do |ticker, dates|
|
||||
next unless issuable.owns_ticker?(ticker)
|
||||
|
||||
oldest_date = dates.min
|
||||
expected_price_count = (oldest_date..Date.current).count
|
||||
prices = Security::Price.find_prices(ticker: ticker, start_date: oldest_date)
|
||||
|
@ -19,4 +24,10 @@ class Issue::PricesMissing < Issue
|
|||
|
||||
stale
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def initialize_missing_prices
|
||||
self.missing_prices ||= {}
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue