Modified events with sport-id and match_id, same for players
This commit is contained in:
1 parent
1c4480b014
commit
9978b0f76f
12 files changed
+205
-152
No files matched your search
+1
-1
@@ -12,7 +12,7 @@ class StatistikoEventsForm
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
DateTimePicker::make('starttime'),
|
||||
DateTimePicker::make('starttime')->native(false),
|
||||
TextInput::make('season'),
|
||||
TextInput::make('gls_h'),
|
||||
TextInput::make('gls_a'),
|
||||
|
||||
+1
-6
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\StatistikoImports\Schemas;
|
||||
|
||||
use App\Models\Sport;
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Schemas\Components\Icon;
|
||||
@@ -14,15 +13,11 @@ class StatistikoImportForm
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
Select::make('sport_id')
|
||||
->required()
|
||||
->label('Sport')
|
||||
->options(fn () => Sport::query()->where('is_active', 1)->pluck('name', 'id')),
|
||||
Select::make('data_type')
|
||||
->required()
|
||||
->allowHtml()
|
||||
->options([
|
||||
'personal' => '<span class="text-blue-500">Personal detail player</span>',
|
||||
'personal' => '<span class="text-blue-500">Personals</span>',
|
||||
'events' => '<span class="text-green-500">Events</span>',
|
||||
'fixtures' => '<span class="text-orange-500">Fixtures</span>',
|
||||
'player' => '<span class="text-pink-600">Player</span>',
|
||||
|
||||
+2
-7
@@ -22,17 +22,12 @@ class StatistikoImportsTable
|
||||
return $table
|
||||
->striped()
|
||||
->columns([
|
||||
IconColumn::make('sport.icon')
|
||||
->label('Sport')
|
||||
->icon(fn ($record) => $record->sport->icon)
|
||||
->tooltip(fn ($record) => $record->id)
|
||||
->visibleFrom('lg'),
|
||||
SelectColumn::make('data_type')
|
||||
->native(false)
|
||||
->width('2rem')
|
||||
->allowOptionsHtml()
|
||||
->options([
|
||||
'personal' => '<span class="text-blue-500">Personal details</span>',
|
||||
'personal' => '<span class="text-blue-500">Personals</span>',
|
||||
'events' => '<span class="text-green-500">Events</span>',
|
||||
'fixtures' => '<span class="text-orange-500">Fixtures</span>',
|
||||
'player' => '<span class="text-amber-500">Player</span>',
|
||||
@@ -41,7 +36,7 @@ class StatistikoImportsTable
|
||||
->searchable()
|
||||
->label('Name'),
|
||||
IconColumn::make('has_run')
|
||||
->label('Import')
|
||||
->label('Imported')
|
||||
->alignCenter()
|
||||
->boolean()
|
||||
->falseColor('gray'),
|
||||
|
||||
@@ -9,45 +9,46 @@ use Spatie\SimpleExcel\SimpleExcelReader;
|
||||
|
||||
class ImportEvents
|
||||
{
|
||||
public static function run(string $filePath, int $sport_id): void
|
||||
public static function run(string $filePath): void
|
||||
{
|
||||
$now = now()->format('Y-m-d H:i:s');
|
||||
|
||||
SimpleExcelReader::create(storage_path('app/public/'.$filePath))
|
||||
->getRows()
|
||||
->chunk(1000)
|
||||
->each(function (LazyCollection $chunk) use ($now, $sport_id) {
|
||||
->each(function (LazyCollection $chunk) use ($now) {
|
||||
|
||||
foreach ($chunk as $row) {
|
||||
|
||||
$row = array_values($row);
|
||||
|
||||
StatistikoEvent::where('sport_id', $sport_id)
|
||||
->where('league_id', $row[0])
|
||||
->where('home_id', $row[1])
|
||||
->where('away_id', $row[2])
|
||||
->where('starttime', Carbon::parse($row[3])->toIso8601String())
|
||||
StatistikoEvent::where('match_id', $row[0])
|
||||
->where('sport_id', $row[1])
|
||||
->where('league_id', $row[2])
|
||||
->where('home_id', $row[3])
|
||||
->where('away_id', $row[4])
|
||||
->where('starttime', Carbon::parse($row[5])->toIso8601String())
|
||||
->update(
|
||||
[
|
||||
'season' => $row[4],
|
||||
'gls_h' => $row[5],
|
||||
'gls_a' => $row[6],
|
||||
'crn_h' => $row[7],
|
||||
'crn_a' => $row[8],
|
||||
'fls_h' => $row[9],
|
||||
'fls_a' => $row[10],
|
||||
'ofs_h' => $row[11],
|
||||
'ofs_a' => $row[12],
|
||||
'snt_h' => $row[13],
|
||||
'snt_a' => $row[14],
|
||||
'tsh_h' => $row[15],
|
||||
'tsh_a' => $row[16],
|
||||
'crd_h' => $row[17],
|
||||
'crd_a' => $row[18],
|
||||
'exp_home' => $row[19],
|
||||
'exp_away' => $row[20],
|
||||
'exp_handicap' => $row[21],
|
||||
'exp_total' => $row[22],
|
||||
'season' => $row[6],
|
||||
'gls_h' => $row[7],
|
||||
'gls_a' => $row[8],
|
||||
'crn_h' => $row[9],
|
||||
'crn_a' => $row[10],
|
||||
'fls_h' => $row[11],
|
||||
'fls_a' => $row[12],
|
||||
'ofs_h' => $row[13],
|
||||
'ofs_a' => $row[14],
|
||||
'snt_h' => $row[15],
|
||||
'snt_a' => $row[16],
|
||||
'tsh_h' => $row[17],
|
||||
'tsh_a' => $row[18],
|
||||
'crd_h' => $row[19],
|
||||
'crd_a' => $row[20],
|
||||
'exp_home' => $row[21],
|
||||
'exp_away' => $row[22],
|
||||
'exp_handicap' => $row[23],
|
||||
'exp_total' => $row[24],
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
],
|
||||
|
||||
@@ -27,7 +27,6 @@ class StatistikoImporter
|
||||
$table = $record['data_type'];
|
||||
|
||||
$filePath = $record['file_name'];
|
||||
$sport_id = $record['sport_id'];
|
||||
|
||||
ImportBenchmark::start($table);
|
||||
|
||||
@@ -36,10 +35,10 @@ class StatistikoImporter
|
||||
ImportPersonal::run($filePath);
|
||||
break;
|
||||
case 'events':
|
||||
ImportEvents::run($filePath, $sport_id);
|
||||
ImportEvents::run($filePath);
|
||||
break;
|
||||
case 'fixtures':
|
||||
ImportFixtures::run($filePath, $sport_id);
|
||||
ImportFixtures::run($filePath);
|
||||
break;
|
||||
case 'player':
|
||||
break;
|
||||
|
||||
@@ -15,6 +15,7 @@ class StatistikoEvent extends Model
|
||||
|
||||
protected $fillable = [
|
||||
'sport_id',
|
||||
'match_id',
|
||||
'league_id',
|
||||
'home_id',
|
||||
'away_id',
|
||||
|
||||
Reference in new issue
Block a user