fix:exclude wishlists from performance chart
This commit is contained in:
@@ -22,6 +22,7 @@ class DashboardController extends Controller
|
|||||||
return
|
return
|
||||||
Holding::query()
|
Holding::query()
|
||||||
->myHoldings()
|
->myHoldings()
|
||||||
|
->withoutWishlists()
|
||||||
->withPortfolioMetrics()
|
->withPortfolioMetrics()
|
||||||
->first();
|
->first();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,6 +46,12 @@ class DailyChange extends Model
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function scopeWithoutWishlists($query) {
|
||||||
|
return $query->whereHas('portfolio', function ($query) {
|
||||||
|
$query->where('portfolios.wishlist', 0);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public function portfolio()
|
public function portfolio()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -155,8 +155,9 @@ class Holding extends Model
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function scopeWithoutWishlists($query) {
|
public function scopeWithoutWishlists($query) {
|
||||||
return $query->join('portfolios', 'portfolios.id', 'holdings.portfolio_id')
|
return $query->whereHas('portfolio', function ($query) {
|
||||||
->where('portfolios.wishlist', 0);
|
$query->where('portfolios.wishlist', 0);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public function scopeMyHoldings($query, $userId = null)
|
public function scopeMyHoldings($query, $userId = null)
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ new class extends Component {
|
|||||||
SUM(total_dividends_earned) as total_dividends_earned
|
SUM(total_dividends_earned) as total_dividends_earned
|
||||||
*/
|
*/
|
||||||
')
|
')
|
||||||
|
->withoutWishlists()
|
||||||
->groupBy('date')
|
->groupBy('date')
|
||||||
->orderBy('date');
|
->orderBy('date');
|
||||||
|
|
||||||
@@ -60,7 +61,7 @@ new class extends Component {
|
|||||||
|
|
||||||
$dailyChangeQuery->whereDate('date', '>=', now()->{$filterMethod['method']}(...$filterMethod['args']));
|
$dailyChangeQuery->whereDate('date', '>=', now()->{$filterMethod['method']}(...$filterMethod['args']));
|
||||||
}
|
}
|
||||||
|
// dd($dailyChangeQuery->toSql());
|
||||||
$dailyChange = $dailyChangeQuery->get();
|
$dailyChange = $dailyChangeQuery->get();
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
|||||||
Reference in New Issue
Block a user