chore: code style

This commit is contained in:
hackerESQ
2025-01-28 17:14:49 -06:00
parent c4736fae70
commit e8ef0921ad
123 changed files with 1051 additions and 1197 deletions
+10 -10
View File
@@ -2,9 +2,9 @@
namespace Database\Seeders;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
class MarketDataSeeder extends Seeder
{
@@ -14,7 +14,7 @@ class MarketDataSeeder extends Seeder
* Run the database seeds.
*/
public function run(): void
{
{
$chunkSize = 500;
// Path to the CSV file
@@ -29,7 +29,7 @@ class MarketDataSeeder extends Seeder
while (($row = fgetcsv($handle, 0, ',')) !== false) {
if (!$header) {
if (! $header) {
// header must be the first row
$header = $row;
@@ -40,31 +40,31 @@ class MarketDataSeeder extends Seeder
$data = array_combine($header, $row);
$rows[] = [
'symbol' => $data['symbol'],
'name' => $data['name'],
'symbol' => $data['symbol'],
'name' => $data['name'],
'meta_data' => json_encode([
'country' => $data['country'],
'first_trade_year' => $data['first_trade_year'],
'sector' => $data['sector'],
'industry' => $data['industry'],
]),
]),
];
$rowCount++;
if ($rowCount % $chunkSize == 0) {
DB::table('market_data')->insertOrIgnore($rows);
$rows = [];
$rows = [];
}
} catch (\Throwable $e) {
throw new \Exception('Error: '. $e->getMessage());
throw new \Exception('Error: '.$e->getMessage());
}
}
}
// final clean up
if (!empty($rows)) {
if (! empty($rows)) {
DB::table('market_data')->insertOrIgnore($rows);
}