fix:speed up daily change sync

This commit is contained in:
hackerESQ
2024-10-25 21:06:45 -05:00
parent 0409677626
commit ff476ad406
+12 -3
View File
@@ -190,9 +190,18 @@ class Portfolio extends Model
if (!empty($total_performance)) {
DB::transaction(function () use ($total_performance) {
$this->daily_change()->delete();
DailyChange::insert($total_performance);
$this->daily_change()->upsert(
$total_performance,
['date', 'portfolio_id'],
[
'total_market_value',
'total_cost_basis',
'total_gain',
'realized_gains',
'total_dividends_earned'
]
);
});
}
}