diff --git a/app/Console/Commands/RefreshDividendData.php b/app/Console/Commands/RefreshDividendData.php index 07925d5..652af38 100644 --- a/app/Console/Commands/RefreshDividendData.php +++ b/app/Console/Commands/RefreshDividendData.php @@ -13,7 +13,8 @@ class RefreshDividendData extends Command * * @var string */ - protected $signature = 'refresh:dividend-data'; + protected $signature = 'refresh:dividend-data + {--force : Refresh all holdings}'; /** * The console command description. @@ -39,9 +40,13 @@ class RefreshDividendData extends Command */ public function handle() { - $holdings = Holding::where('quantity', '>', 0)->distinct()->get(['symbol']); + $holdings = Holding::distinct(); - foreach ($holdings as $holding) { + if (!($this->option('force') ?? false)) { + $holdings->where('quantity', '>', 0); + } + + foreach ($holdings->get(['symbol']) as $holding) { $this->line('Refreshing ' . $holding->symbol); Dividend::refreshDividendData($holding->symbol); diff --git a/app/Console/Commands/RefreshSplitData.php b/app/Console/Commands/RefreshSplitData.php index bc0ce2f..a358630 100644 --- a/app/Console/Commands/RefreshSplitData.php +++ b/app/Console/Commands/RefreshSplitData.php @@ -14,7 +14,7 @@ class RefreshSplitData extends Command * @var string */ protected $signature = 'refresh:split-data - {--force= : Don\'t ask to confirm.}'; + {--force : Refresh all holdings}'; /** * The console command description. @@ -40,9 +40,13 @@ class RefreshSplitData extends Command */ public function handle() { - $holdings = Holding::where('quantity', '>', 0)->distinct()->get(['symbol']); + $holdings = Holding::distinct(); - foreach ($holdings as $holding) { + if (!($this->option('force') ?? false)) { + $holdings->where('quantity', '>', 0); + } + + foreach ($holdings->get(['symbol']) as $holding) { $this->line('Refreshing ' . $holding->symbol); Split::refreshSplitData($holding->symbol);