fix: multi currency seeders
This commit is contained in:
@@ -97,9 +97,14 @@ return new class extends Migration
|
||||
'--force' => true,
|
||||
]);
|
||||
|
||||
CurrencyRate::timeSeriesRates(
|
||||
Holding::all()->groupBy('market_data.currency')->keys()->toArray(),
|
||||
Transaction::min('date')
|
||||
Holding::all()->groupBy('market_data.currency')->keys()->each(
|
||||
fn ($currency) => dispatch(
|
||||
function () use ($currency) {
|
||||
CurrencyRate::timeSeriesRates(
|
||||
$currency,
|
||||
Transaction::min('date')
|
||||
);
|
||||
})
|
||||
);
|
||||
|
||||
CurrencyRate::refreshCurrencyData();
|
||||
|
||||
@@ -54,8 +54,7 @@ class MarketDataSeeder extends Seeder
|
||||
$rowCount++;
|
||||
|
||||
if ($rowCount % $chunkSize == 0) {
|
||||
DB::table('market_data')->upsert($this->rows, ['symbol'], ['name', 'currency', 'meta_data']);
|
||||
$this->rows = [];
|
||||
$this->bulkInsert($this->rows);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -77,11 +76,14 @@ class MarketDataSeeder extends Seeder
|
||||
}
|
||||
}
|
||||
|
||||
public function bulkInsert(array $rows)
|
||||
public function bulkInsert($rows)
|
||||
{
|
||||
try {
|
||||
|
||||
DB::table('market_data')->insertOrIgnore($rows);
|
||||
dispatch(
|
||||
fn () => DB::table('market_data')->upsert($rows, ['symbol'], ['name', 'currency', 'meta_data'])
|
||||
);
|
||||
|
||||
$this->rows = [];
|
||||
|
||||
} catch (\Throwable $e) {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user