fix import player, new columns remove telescope, consider emty vars in PlayerDataMerge

This commit is contained in:
salam committed 2026-11-01 12:24:25 +01:00
1 parent 43013d3eec
commit bef576616f
14 files changed
+553 -1437

No files matched your search

@@ -7,6 +7,8 @@ use Illuminate\Support\Carbon;
use Illuminate\Support\LazyCollection;
use Spatie\SimpleExcel\SimpleExcelReader;
use function PHPUnit\Framework\isEmpty;
class ImportFixtures
{
public static function run(string $filePath): void
@@ -20,6 +22,10 @@ class ImportFixtures
$row = array_values($row);
if (isEmpty($row[1])) {
return false;
}
/*
0 => 1
1 => 87
+12 -29
View File
@@ -3,9 +3,12 @@
namespace App\Filament\Imports\Helper;
use App\Models\StatistikoPlayer;
use Illuminate\Support\Carbon;
use Illuminate\Support\LazyCollection;
use Spatie\SimpleExcel\SimpleExcelReader;
use function PHPUnit\Framework\isEmpty;
class ImportPlayer
{
public static function run(string $filePath): void
@@ -14,6 +17,7 @@ class ImportPlayer
'sport_id',
'match_id',
'ss_player_id',
'starttime',
'activeteam_id',
'playersubstitute_id',
'goals',
@@ -78,11 +82,12 @@ class ImportPlayer
'player_position',
'playerrating_value',
'tm_player_id',
'season',
];
SimpleExcelReader::create(storage_path('app/public/'.$filePath))
->getRows()
->chunk(1000)
->chunk(200)
->each(function (LazyCollection $chunk) use ($fieldnames) {
foreach ($chunk as $row) {
@@ -95,9 +100,14 @@ class ImportPlayer
$update_array = [];
foreach ($fieldnames as $key => $name) {
if ($key == 1) {
if (isEmpty($row[$key])) {
return false;
}
$match_id = (int) $row[$key];
} elseif ($key == 2) {
$ss_player_id = (int) $row[$key];
} elseif ($key == 3) {
$update_array['starttime'] = Carbon::parse($row[$key], config('app.timezone'))->setTimezone('UTC');
} else {
$update_array[$name] = $row[$key];
}
@@ -111,34 +121,7 @@ class ImportPlayer
$update_array
);
}
// $collection = [];
// foreach ($chunk as $row) {
// $update_array = [];
// foreach ($row as $name => $value) {
// switch ($name) {
// case 'SS_MATCH_ID':
// $update_array['match_id'] = (int) $value;
// break;
// case 'SS_PLAYER_ID':
// $update_array['ss_player_id'] = (int) $value;
// break;
// default:
// $name = strtolower($name);
// $update_array[$name] = $value;
// break;
// }
// }
// $collection[] = $update_array;
// }
// StatistikoPlayer::upsert(
// $collection,
// uniqueBy: [
// 'match_id',
// 'ss_player_id',
// ],
// update: $fieldnames);
});
}
}