fix:improve import performance
This commit is contained in:
@@ -79,7 +79,7 @@ class DailyChangesSheet implements ToCollection, WithHeadingRow, WithValidation,
|
|||||||
|
|
||||||
public function batchSize(): int
|
public function batchSize(): int
|
||||||
{
|
{
|
||||||
return 750;
|
return 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function rules(): array
|
public function rules(): array
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ namespace App\Imports\Sheets;
|
|||||||
|
|
||||||
use App\Imports\ValidatesPortfolioAccess;
|
use App\Imports\ValidatesPortfolioAccess;
|
||||||
use App\Models\Holding;
|
use App\Models\Holding;
|
||||||
use App\Models\Portfolio;
|
|
||||||
use App\Models\Transaction;
|
use App\Models\Transaction;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use App\Models\BackupImport;
|
use App\Models\BackupImport;
|
||||||
@@ -85,7 +84,8 @@ class TransactionsSheet implements ToCollection, WithHeadingRow, WithValidation,
|
|||||||
);
|
);
|
||||||
|
|
||||||
// stub out related holdings
|
// stub out related holdings
|
||||||
$chunk->unique('symbol')->each(function($holding) {
|
$chunk->unique(fn($item) => $item['symbol'] . $item['portfolio_id'])
|
||||||
|
->each(function($holding) {
|
||||||
|
|
||||||
Holding::firstOrCreate([
|
Holding::firstOrCreate([
|
||||||
'symbol' => $holding['symbol'],
|
'symbol' => $holding['symbol'],
|
||||||
|
|||||||
Reference in New Issue
Block a user