update import opetion by upload
This commit is contained in:
1 parent
37d28eec21
commit
0221ace4d2
15 files changed
+194
-253
No files matched your search
@@ -1,11 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Clusters\StaticData\Resources\Players\Pages;
|
|
||||||
|
|
||||||
use App\Filament\Clusters\StaticData\Resources\Players\PlayerResource;
|
|
||||||
use Filament\Resources\Pages\CreateRecord;
|
|
||||||
|
|
||||||
class CreatePlayer extends CreateRecord
|
|
||||||
{
|
|
||||||
protected static string $resource = PlayerResource::class;
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Clusters\StaticData\Resources\Players\Pages;
|
|
||||||
|
|
||||||
use App\Filament\Clusters\StaticData\Resources\Players\PlayerResource;
|
|
||||||
use Filament\Actions\DeleteAction;
|
|
||||||
use Filament\Resources\Pages\EditRecord;
|
|
||||||
|
|
||||||
class EditPlayer extends EditRecord
|
|
||||||
{
|
|
||||||
protected static string $resource = PlayerResource::class;
|
|
||||||
|
|
||||||
protected function getHeaderActions(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
DeleteAction::make(),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Clusters\StaticData\Resources\Players\Pages;
|
|
||||||
|
|
||||||
use App\Filament\Clusters\StaticData\Resources\Players\PlayerResource;
|
|
||||||
use App\Filament\Imports\PlayerImporter;
|
|
||||||
use Filament\Actions\CreateAction;
|
|
||||||
use Filament\Actions\ImportAction;
|
|
||||||
use Filament\Resources\Pages\ListRecords;
|
|
||||||
|
|
||||||
class ListPlayers extends ListRecords
|
|
||||||
{
|
|
||||||
protected static string $resource = PlayerResource::class;
|
|
||||||
|
|
||||||
protected function getHeaderActions(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
CreateAction::make()
|
|
||||||
->label('New')
|
|
||||||
->icon('phosphor-plus'),
|
|
||||||
ImportAction::make('importPlayer')
|
|
||||||
->icon('phosphor-upload')
|
|
||||||
->label('Import')
|
|
||||||
->modalDescription('Separator comma ",", First line: "name,tm_player_id"')
|
|
||||||
->importer(PlayerImporter::class),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Clusters\StaticData\Resources\Players;
|
|
||||||
|
|
||||||
use App\Filament\Clusters\StaticData\Resources\Players\Pages\ListPlayers;
|
|
||||||
use App\Filament\Clusters\StaticData\Resources\Players\Schemas\PlayerForm;
|
|
||||||
use App\Filament\Clusters\StaticData\Resources\Players\Tables\PlayersTable;
|
|
||||||
use App\Filament\Clusters\StaticData\StaticDataCluster;
|
|
||||||
use App\Models\Player;
|
|
||||||
// use BackedEnum;
|
|
||||||
use Filament\Resources\Resource;
|
|
||||||
use Filament\Schemas\Schema;
|
|
||||||
use Filament\Tables\Table;
|
|
||||||
|
|
||||||
class PlayerResource extends Resource
|
|
||||||
{
|
|
||||||
protected static ?string $model = Player::class;
|
|
||||||
|
|
||||||
protected static bool $shouldRegisterNavigation = false;
|
|
||||||
|
|
||||||
protected static ?string $cluster = StaticDataCluster::class;
|
|
||||||
|
|
||||||
protected static ?string $recordTitleAttribute = 'name';
|
|
||||||
|
|
||||||
public static function form(Schema $schema): Schema
|
|
||||||
{
|
|
||||||
return PlayerForm::configure($schema);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function table(Table $table): Table
|
|
||||||
{
|
|
||||||
return PlayersTable::configure($table);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getPages(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'index' => ListPlayers::route('/'),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getNavigationBadge(): ?string
|
|
||||||
{
|
|
||||||
return parent::getEloquentQuery()->count();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Clusters\StaticData\Resources\Players\Schemas;
|
|
||||||
|
|
||||||
use Filament\Forms\Components\TextInput;
|
|
||||||
use Filament\Schemas\Schema;
|
|
||||||
|
|
||||||
class PlayerForm
|
|
||||||
{
|
|
||||||
public static function configure(Schema $schema): Schema
|
|
||||||
{
|
|
||||||
return $schema
|
|
||||||
->components([
|
|
||||||
TextInput::make('name'),
|
|
||||||
TextInput::make('tm_player_id')->afterLabel(['Must be unique']),
|
|
||||||
TextInput::make('ss_player_id')->afterLabel(['Must be unique']),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Clusters\StaticData\Resources\Players\Tables;
|
|
||||||
|
|
||||||
use Filament\Actions\DeleteAction;
|
|
||||||
use Filament\Actions\EditAction;
|
|
||||||
use Filament\Tables\Columns\Layout\Stack;
|
|
||||||
use Filament\Tables\Columns\TextColumn;
|
|
||||||
use Filament\Tables\Table;
|
|
||||||
|
|
||||||
class PlayersTable
|
|
||||||
{
|
|
||||||
public static function configure(Table $table): Table
|
|
||||||
{
|
|
||||||
return $table
|
|
||||||
->striped()
|
|
||||||
->columns([
|
|
||||||
Stack::make([
|
|
||||||
TextColumn::make('name')
|
|
||||||
->searchable(),
|
|
||||||
TextColumn::make('tm_player_id')
|
|
||||||
->badge()
|
|
||||||
->searchable(),
|
|
||||||
]),
|
|
||||||
])
|
|
||||||
->contentGrid([
|
|
||||||
'md' => 3,
|
|
||||||
'xl' => 5,
|
|
||||||
])
|
|
||||||
->recordActions([
|
|
||||||
EditAction::make()->hiddenLabel(),
|
|
||||||
DeleteAction::make()->hiddenLabel(),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+4
-4
@@ -17,10 +17,10 @@ class StatistikoImportForm
|
|||||||
->required()
|
->required()
|
||||||
->allowHtml()
|
->allowHtml()
|
||||||
->options([
|
->options([
|
||||||
'details' => '<span class="text-blue-500">Details</span>',
|
'details' => '<span class="text-blue-500">Player Details</span>',
|
||||||
'events' => '<span class="text-green-500">Events</span>',
|
'player' => '<span class="text-pink-600">Player History</span>',
|
||||||
'fixtures' => '<span class="text-orange-500">Fixtures</span>',
|
'fixtures' => '<span class="text-orange-500">Fixtures Upcoming</span>',
|
||||||
'player' => '<span class="text-pink-600">Player</span>',
|
'events' => '<span class="text-green-500">Events History</span>',
|
||||||
]),
|
]),
|
||||||
|
|
||||||
FileUpload::make('file_name')
|
FileUpload::make('file_name')
|
||||||
|
|||||||
+20
-8
@@ -25,13 +25,12 @@ class StatistikoImportsTable
|
|||||||
->columns([
|
->columns([
|
||||||
SelectColumn::make('data_type')
|
SelectColumn::make('data_type')
|
||||||
->native(false)
|
->native(false)
|
||||||
->width('2rem')
|
|
||||||
->allowOptionsHtml()
|
->allowOptionsHtml()
|
||||||
->options([
|
->options([
|
||||||
'details' => '<span class="text-blue-500">Details</span>',
|
'details' => '<span class="text-blue-500">Player Details</span>',
|
||||||
'events' => '<span class="text-green-500">Events</span>',
|
'player' => '<span class="text-pink-600">Player History</span>',
|
||||||
'fixtures' => '<span class="text-orange-500">Fixtures</span>',
|
'fixtures' => '<span class="text-orange-500">Fixtures Upcoming</span>',
|
||||||
'player' => '<span class="text-pink-600">Player</span>',
|
'events' => '<span class="text-green-500">Events History</span>',
|
||||||
]),
|
]),
|
||||||
TextColumn::make('file_name_original')
|
TextColumn::make('file_name_original')
|
||||||
->searchable()
|
->searchable()
|
||||||
@@ -58,15 +57,28 @@ class StatistikoImportsTable
|
|||||||
->deferFilters(false)
|
->deferFilters(false)
|
||||||
->recordActions([
|
->recordActions([
|
||||||
ActionGroup::make([
|
ActionGroup::make([
|
||||||
Action::make('Import')
|
Action::make('import')
|
||||||
->label('Import to DB')
|
->label('Import')
|
||||||
|
->color('success')
|
||||||
|
->tooltip('Import is much faster but does no check for doubles')
|
||||||
->icon('phosphor-database')
|
->icon('phosphor-database')
|
||||||
->action(fn ($record) => StatistikoImporter::run($record))
|
->action(fn ($record) => StatistikoImporter::run($record, 'import'))
|
||||||
->successNotification(
|
->successNotification(
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->info()
|
->info()
|
||||||
->title('Import started')
|
->title('Import started')
|
||||||
),
|
),
|
||||||
|
Action::make('update')
|
||||||
|
->label('Update')
|
||||||
|
->color('info')
|
||||||
|
->tooltip('Compares ervery row in database and takes time')
|
||||||
|
->icon('phosphor-database')
|
||||||
|
->action(fn ($record) => StatistikoImporter::run($record, 'update'))
|
||||||
|
->successNotification(
|
||||||
|
Notification::make()
|
||||||
|
->info()
|
||||||
|
->title('Update started')
|
||||||
|
),
|
||||||
DeleteAction::make()
|
DeleteAction::make()
|
||||||
->successNotificationTitle('File deleted')
|
->successNotificationTitle('File deleted')
|
||||||
->label('Delete file'),
|
->label('Delete file'),
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace App\Filament\Imports\Helper;
|
namespace App\Filament\Imports\Helper;
|
||||||
|
|
||||||
use Filament\Notifications\Notification;
|
use Filament\Notifications\Notification;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Support\HtmlString;
|
use Illuminate\Support\HtmlString;
|
||||||
|
|
||||||
@@ -46,7 +47,7 @@ class ImportBenchmark
|
|||||||
$str .= '<br/>SQL: '.number_format($queriesCount);
|
$str .= '<br/>SQL: '.number_format($queriesCount);
|
||||||
$str .= '<br/>ROWS: '.number_format($rowDiff);
|
$str .= '<br/>ROWS: '.number_format($rowDiff);
|
||||||
|
|
||||||
$recipient = auth()->user();
|
$recipient = Auth::user();
|
||||||
|
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->success()
|
->success()
|
||||||
|
|||||||
@@ -9,22 +9,47 @@ use Spatie\SimpleExcel\SimpleExcelReader;
|
|||||||
|
|
||||||
class ImportDetails
|
class ImportDetails
|
||||||
{
|
{
|
||||||
public static function run(string $filePath): void
|
public static function run(string $filePath, string $importmode): void
|
||||||
{
|
{
|
||||||
$now = now()->format('Y-m-d H:i:s');
|
$now = now()->format('Y-m-d H:i:s');
|
||||||
|
|
||||||
SimpleExcelReader::create(storage_path('app/public/'.$filePath))
|
SimpleExcelReader::create(storage_path('app/public/'.$filePath))
|
||||||
->getRows()
|
->getRows()
|
||||||
->chunk(1000)
|
->chunk(1000)
|
||||||
->each(function (LazyCollection $chunk) use ($now) {
|
->each(function (LazyCollection $chunk) use ($now, $importmode) {
|
||||||
|
|
||||||
foreach ($chunk as $row) {
|
foreach ($chunk as $row) {
|
||||||
|
|
||||||
$row = array_values($row);
|
$row = array_values($row);
|
||||||
|
|
||||||
StatistikoDetail::where('tm_player_id', $row[0])
|
if ($importmode == 'update') {
|
||||||
->update(
|
StatistikoDetail::where('tm_player_id', $row[0])
|
||||||
|
->update(
|
||||||
|
[
|
||||||
|
'name' => $row[1],
|
||||||
|
'birthdate' => Carbon::parse($row[2])->toDateString(),
|
||||||
|
'height' => $row[3],
|
||||||
|
'nationality' => $row[4],
|
||||||
|
'position' => $row[5],
|
||||||
|
'sport_radar_id' => $row[6],
|
||||||
|
'id_squadra_tm' => $row[7],
|
||||||
|
'full_name' => $row[8],
|
||||||
|
'no_specialities' => $row[9],
|
||||||
|
'txodds_id' => $row[10],
|
||||||
|
'national_team_id' => $row[11],
|
||||||
|
'last_update' => Carbon::parse($row[12])->toDateString(),
|
||||||
|
'league_code' => $row[13],
|
||||||
|
'team_code' => $row[14],
|
||||||
|
'team_name' => $row[15],
|
||||||
|
'created_at' => $now,
|
||||||
|
'updated_at' => $now,
|
||||||
|
],
|
||||||
|
['upsert' => true],
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
StatistikoDetail::insert(
|
||||||
[
|
[
|
||||||
|
'tm_player_id', $row[0],
|
||||||
'name' => $row[1],
|
'name' => $row[1],
|
||||||
'birthdate' => Carbon::parse($row[2])->toDateString(),
|
'birthdate' => Carbon::parse($row[2])->toDateString(),
|
||||||
'height' => $row[3],
|
'height' => $row[3],
|
||||||
@@ -42,10 +67,9 @@ class ImportDetails
|
|||||||
'team_name' => $row[15],
|
'team_name' => $row[15],
|
||||||
'created_at' => $now,
|
'created_at' => $now,
|
||||||
'updated_at' => $now,
|
'updated_at' => $now,
|
||||||
],
|
]
|
||||||
['upsert' => true],
|
|
||||||
);
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,37 +9,71 @@ use Spatie\SimpleExcel\SimpleExcelReader;
|
|||||||
|
|
||||||
class ImportEvents
|
class ImportEvents
|
||||||
{
|
{
|
||||||
public static function run(string $filePath): void
|
public static function run(string $filePath, string $importmode): void
|
||||||
{
|
{
|
||||||
$now = now()->format('Y-m-d H:i:s');
|
$now = now()->format('Y-m-d H:i:s');
|
||||||
|
|
||||||
SimpleExcelReader::create(storage_path('app/public/'.$filePath))
|
SimpleExcelReader::create(storage_path('app/public/'.$filePath))
|
||||||
->getRows()
|
->getRows()
|
||||||
->chunk(1000)
|
->chunk(1000)
|
||||||
->each(function (LazyCollection $chunk) use ($now) {
|
->each(function (LazyCollection $chunk) use ($now, $importmode) {
|
||||||
|
|
||||||
foreach ($chunk as $row) {
|
foreach ($chunk as $row) {
|
||||||
|
|
||||||
$row = array_values($row);
|
$row = array_values($row);
|
||||||
|
|
||||||
dd($row);
|
if ($importmode == 'update') {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
0 => 14082828
|
0 => 14082828
|
||||||
1 => 1
|
1 => 1
|
||||||
2 => 12
|
2 => 12
|
||||||
3 => 1661
|
3 => 1661
|
||||||
4 => 4781
|
4 => 4781
|
||||||
*/
|
*/
|
||||||
|
|
||||||
StatistikoEvent::where('match_id', $row[0])
|
StatistikoEvent::where('match_id', $row[0])
|
||||||
->where('sport_id', $row[1])
|
->where('sport_id', $row[1])
|
||||||
->where('league_id', $row[2])
|
->where('league_id', $row[2])
|
||||||
->where('home_id', $row[3])
|
->where('home_id', $row[3])
|
||||||
->where('away_id', $row[4])
|
->where('away_id', $row[4])
|
||||||
->where('starttime', Carbon::parse($row[5])->toIso8601String())
|
->where('starttime', Carbon::parse($row[5])->toIso8601String())
|
||||||
->update(
|
->update(
|
||||||
|
[
|
||||||
|
'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],
|
||||||
|
'result_code' => $row[25], // w, d, l
|
||||||
|
'created_at' => $now,
|
||||||
|
'updated_at' => $now,
|
||||||
|
],
|
||||||
|
['upsert' => true],
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
StatistikoEvent::import(
|
||||||
[
|
[
|
||||||
|
'match_id', $row[0],
|
||||||
|
'sport_id', $row[1],
|
||||||
|
'league_id', $row[2],
|
||||||
|
'home_id', $row[3],
|
||||||
|
'away_id', $row[4],
|
||||||
|
'starttime', Carbon::parse($row[5])->toIso8601String(),
|
||||||
'season' => $row[6],
|
'season' => $row[6],
|
||||||
'gls_h' => $row[7],
|
'gls_h' => $row[7],
|
||||||
'gls_a' => $row[8],
|
'gls_a' => $row[8],
|
||||||
@@ -62,9 +96,9 @@ class ImportEvents
|
|||||||
'result_code' => $row[25], // w, d, l
|
'result_code' => $row[25], // w, d, l
|
||||||
'created_at' => $now,
|
'created_at' => $now,
|
||||||
'updated_at' => $now,
|
'updated_at' => $now,
|
||||||
],
|
]
|
||||||
['upsert' => true],
|
|
||||||
);
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,12 +9,12 @@ use Spatie\SimpleExcel\SimpleExcelReader;
|
|||||||
|
|
||||||
class ImportFixtures
|
class ImportFixtures
|
||||||
{
|
{
|
||||||
public static function run(string $filePath): void
|
public static function run(string $filePath, string $importmode): void
|
||||||
{
|
{
|
||||||
SimpleExcelReader::create(storage_path('app/public/'.$filePath))
|
SimpleExcelReader::create(storage_path('app/public/'.$filePath))
|
||||||
->getRows()
|
->getRows()
|
||||||
->chunk(200)
|
->chunk(200)
|
||||||
->each(function (LazyCollection $chunk) {
|
->each(function (LazyCollection $chunk) use ($importmode) {
|
||||||
|
|
||||||
foreach ($chunk as $row) {
|
foreach ($chunk as $row) {
|
||||||
|
|
||||||
@@ -30,16 +30,30 @@ class ImportFixtures
|
|||||||
6 => 1.035168989838
|
6 => 1.035168989838
|
||||||
*/
|
*/
|
||||||
|
|
||||||
StatisticFixtures::updateOrCreate(
|
if ($importmode == 'update') {
|
||||||
[
|
StatisticFixtures::updateOrCreate(
|
||||||
'sport_id' => (int) $row[0],
|
[
|
||||||
'league_id' => (int) $row[1],
|
'sport_id' => (int) $row[0],
|
||||||
'home_id' => (int) $row[2],
|
'league_id' => (int) $row[1],
|
||||||
'away_id' => (int) $row[3],
|
'home_id' => (int) $row[2],
|
||||||
'starttime' => Carbon::parse($row[4])->toDateTimeString(),
|
'away_id' => (int) $row[3],
|
||||||
],
|
'starttime' => Carbon::parse($row[4])->toDateTimeString(),
|
||||||
['exp_home' => (float) $row[5], 'exp_away' => (float) $row[6]]
|
],
|
||||||
);
|
['exp_home' => (float) $row[5], 'exp_away' => (float) $row[6]]
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
StatisticFixtures::insert(
|
||||||
|
[
|
||||||
|
'sport_id' => (int) $row[0],
|
||||||
|
'league_id' => (int) $row[1],
|
||||||
|
'home_id' => (int) $row[2],
|
||||||
|
'away_id' => (int) $row[3],
|
||||||
|
'starttime' => Carbon::parse($row[4])->toDateTimeString(),
|
||||||
|
'exp_home' => (float) $row[5],
|
||||||
|
'exp_away' => (float) $row[6],
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,14 +8,14 @@ use Spatie\SimpleExcel\SimpleExcelReader;
|
|||||||
|
|
||||||
class ImportPlayer
|
class ImportPlayer
|
||||||
{
|
{
|
||||||
public static function run(string $filePath): void
|
public static function run(string $filePath, string $importmode): void
|
||||||
{
|
{
|
||||||
$fieldnames = ['activeteam_id', 'playersubstitute_id', 'goals', 'assists', 'own_goals', 'shots_on_target', 'shots_off_target', 'shots_blocked', 'fouls', 'was_fouled', 'offsides', 'possessions_lost', 'total_tackles', 'touches', 'total_cross', 'cross_done', 'total_dribbles', 'dribbles_won', 'total_ground_duels', 'total_ground_duels_won', 'total_aerial_duels', 'total_duels_aerial_won', 'total_pass', 'pass', 'total_long_balls', 'long_balls', 'blocked_shots', 'clearances', 'dribbled_past', 'hit_woodwork', 'interceptions', 'key_pass', 'last_man_tackle', 'dispossessed', 'clearance_off_line', 'bcc', 'bcm', 'errors_lead_to_a_goal', 'errors_lead_to_a_shot', 'penalty_committed', 'penalty_miss', 'penalty_save', 'penalty_won', 'saves', 'saves_from_in_box', 'total_runs_out', 'runs_out', 'punches', 'good_high_claim', 'minutes_played', 'lineup', 'minute_event_during_the_match', 'type_event_during_the_match', 'description_event_during_the_match', 'subtype_event_during_the_match', 'card_yellow', 'card_yellowred', 'card_red', 'ingamepenalty_missed', 'penaltyshoutout_scored', 'penaltyshoutout_missed', 'player_position', 'playerrating_value'];
|
$fieldnames = ['activeteam_id', 'playersubstitute_id', 'goals', 'assists', 'own_goals', 'shots_on_target', 'shots_off_target', 'shots_blocked', 'fouls', 'was_fouled', 'offsides', 'possessions_lost', 'total_tackles', 'touches', 'total_cross', 'cross_done', 'total_dribbles', 'dribbles_won', 'total_ground_duels', 'total_ground_duels_won', 'total_aerial_duels', 'total_duels_aerial_won', 'total_pass', 'pass', 'total_long_balls', 'long_balls', 'blocked_shots', 'clearances', 'dribbled_past', 'hit_woodwork', 'interceptions', 'key_pass', 'last_man_tackle', 'dispossessed', 'clearance_off_line', 'bcc', 'bcm', 'errors_lead_to_a_goal', 'errors_lead_to_a_shot', 'penalty_committed', 'penalty_miss', 'penalty_save', 'penalty_won', 'saves', 'saves_from_in_box', 'total_runs_out', 'runs_out', 'punches', 'good_high_claim', 'minutes_played', 'lineup', 'minute_event_during_the_match', 'type_event_during_the_match', 'description_event_during_the_match', 'subtype_event_during_the_match', 'card_yellow', 'card_yellowred', 'card_red', 'ingamepenalty_missed', 'penaltyshoutout_scored', 'penaltyshoutout_missed', 'player_position', 'playerrating_value'];
|
||||||
|
|
||||||
SimpleExcelReader::create(storage_path('app/public/'.$filePath))
|
SimpleExcelReader::create(storage_path('app/public/'.$filePath))
|
||||||
->getRows()
|
->getRows()
|
||||||
->chunk(1000)
|
->chunk(1000)
|
||||||
->each(function (LazyCollection $chunk) use ($fieldnames) {
|
->each(function (LazyCollection $chunk) use ($fieldnames, $importmode) {
|
||||||
|
|
||||||
foreach ($chunk as $row) {
|
foreach ($chunk as $row) {
|
||||||
|
|
||||||
@@ -23,19 +23,29 @@ class ImportPlayer
|
|||||||
|
|
||||||
// print_r($row);
|
// print_r($row);
|
||||||
|
|
||||||
$update_array = [];
|
if ($importmode == 'update') {
|
||||||
foreach ($fieldnames as $key => $name) {
|
|
||||||
$offset = (int) $key + 4;
|
$update_array = [];
|
||||||
$update_array[$name] = $row[$offset];
|
foreach ($fieldnames as $key => $name) {
|
||||||
|
$offset = (int) $key + 4;
|
||||||
|
$update_array[$name] = $row[$offset];
|
||||||
|
}
|
||||||
|
|
||||||
|
// dd($update_array);
|
||||||
|
|
||||||
|
StatistikoPlayer::where('sport_id', (int) $row[0])
|
||||||
|
->where('match_id', (int) $row[1])
|
||||||
|
->where('ss_player_id', (int) $row[2])
|
||||||
|
->where('tm_player_id', (int) $row[3])
|
||||||
|
->update($update_array, ['upsert' => true]);
|
||||||
|
} else {
|
||||||
|
$insert_array = [];
|
||||||
|
foreach ($fieldnames as $key => $name) {
|
||||||
|
$insert_array[$name] = $row[$key];
|
||||||
|
}
|
||||||
|
|
||||||
|
StatistikoPlayer::insert($insert_array);
|
||||||
}
|
}
|
||||||
|
|
||||||
// dd($update_array);
|
|
||||||
|
|
||||||
StatistikoPlayer::where('sport_id', (int) $row[0])
|
|
||||||
->where('match_id', (int) $row[1])
|
|
||||||
->where('ss_player_id', (int) $row[2])
|
|
||||||
->where('tm_player_id', (int) $row[3])
|
|
||||||
->update($update_array, ['upsert' => true]);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,30 +19,30 @@ class StatistikoImporter
|
|||||||
|
|
||||||
public static int $startQueries;
|
public static int $startQueries;
|
||||||
|
|
||||||
public static function run($record): void
|
public static function run(object $record, string $importmode): void
|
||||||
{
|
{
|
||||||
error_reporting(E_ALL);
|
error_reporting(E_ALL);
|
||||||
ini_set('display_errors', 1);
|
ini_set('display_errors', 1);
|
||||||
ini_set('max_execution_time', -1);
|
ini_set('max_execution_time', -1);
|
||||||
|
|
||||||
$table = $record['data_type'];
|
$table = $record->data_type;
|
||||||
|
|
||||||
$filePath = $record['file_name'];
|
$filePath = $record->file_name;
|
||||||
|
|
||||||
ImportBenchmark::start($table);
|
ImportBenchmark::start($table);
|
||||||
|
|
||||||
switch ($record['data_type']) {
|
switch ($record['data_type']) {
|
||||||
case 'details':
|
case 'details':
|
||||||
ImportDetails::run($filePath);
|
ImportDetails::run($filePath, $importmode);
|
||||||
break;
|
break;
|
||||||
case 'events':
|
case 'events':
|
||||||
ImportEvents::run($filePath);
|
ImportEvents::run($filePath, $importmode);
|
||||||
break;
|
break;
|
||||||
case 'fixtures':
|
case 'fixtures':
|
||||||
ImportFixtures::run($filePath);
|
ImportFixtures::run($filePath, $importmode);
|
||||||
break;
|
break;
|
||||||
case 'player':
|
case 'player':
|
||||||
ImportPlayer::run($filePath);
|
ImportPlayer::run($filePath, $importmode);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Generated
+27
-23
@@ -2196,25 +2196,26 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "guzzlehttp/guzzle",
|
"name": "guzzlehttp/guzzle",
|
||||||
"version": "7.10.6",
|
"version": "7.11.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/guzzle/guzzle.git",
|
"url": "https://github.com/guzzle/guzzle.git",
|
||||||
"reference": "e7412b3180912c01650cc66647f18c1d1cbe9b94"
|
"reference": "c987f8ce84b8434fa430795eca0f3430663da72b"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/e7412b3180912c01650cc66647f18c1d1cbe9b94",
|
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/c987f8ce84b8434fa430795eca0f3430663da72b",
|
||||||
"reference": "e7412b3180912c01650cc66647f18c1d1cbe9b94",
|
"reference": "c987f8ce84b8434fa430795eca0f3430663da72b",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"ext-json": "*",
|
"ext-json": "*",
|
||||||
"guzzlehttp/promises": "^2.3",
|
"guzzlehttp/promises": "^2.5",
|
||||||
"guzzlehttp/psr7": "^2.8",
|
"guzzlehttp/psr7": "^2.11",
|
||||||
"php": "^7.2.5 || ^8.0",
|
"php": "^7.2.5 || ^8.0",
|
||||||
"psr/http-client": "^1.0",
|
"psr/http-client": "^1.0",
|
||||||
"symfony/deprecation-contracts": "^2.2 || ^3.0"
|
"symfony/deprecation-contracts": "^2.5 || ^3.0",
|
||||||
|
"symfony/polyfill-php80": "^1.24"
|
||||||
},
|
},
|
||||||
"provide": {
|
"provide": {
|
||||||
"psr/http-client-implementation": "1.0"
|
"psr/http-client-implementation": "1.0"
|
||||||
@@ -2303,7 +2304,7 @@
|
|||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/guzzle/guzzle/issues",
|
"issues": "https://github.com/guzzle/guzzle/issues",
|
||||||
"source": "https://github.com/guzzle/guzzle/tree/7.10.6"
|
"source": "https://github.com/guzzle/guzzle/tree/7.11.0"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
@@ -2319,24 +2320,25 @@
|
|||||||
"type": "tidelift"
|
"type": "tidelift"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2026-06-01T13:06:22+00:00"
|
"time": "2026-06-02T12:40:51+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "guzzlehttp/promises",
|
"name": "guzzlehttp/promises",
|
||||||
"version": "2.4.1",
|
"version": "2.5.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/guzzle/promises.git",
|
"url": "https://github.com/guzzle/promises.git",
|
||||||
"reference": "09e8a212562fb1fb6a512c4156ed71525969d6c2"
|
"reference": "4360e982f87f5f258bf872d094647791db2f4c8e"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/guzzle/promises/zipball/09e8a212562fb1fb6a512c4156ed71525969d6c2",
|
"url": "https://api.github.com/repos/guzzle/promises/zipball/4360e982f87f5f258bf872d094647791db2f4c8e",
|
||||||
"reference": "09e8a212562fb1fb6a512c4156ed71525969d6c2",
|
"reference": "4360e982f87f5f258bf872d094647791db2f4c8e",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^7.2.5 || ^8.0"
|
"php": "^7.2.5 || ^8.0",
|
||||||
|
"symfony/deprecation-contracts": "^2.5 || ^3.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"bamarni/composer-bin-plugin": "^1.8.2",
|
"bamarni/composer-bin-plugin": "^1.8.2",
|
||||||
@@ -2386,7 +2388,7 @@
|
|||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/guzzle/promises/issues",
|
"issues": "https://github.com/guzzle/promises/issues",
|
||||||
"source": "https://github.com/guzzle/promises/tree/2.4.1"
|
"source": "https://github.com/guzzle/promises/tree/2.5.0"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
@@ -2402,27 +2404,29 @@
|
|||||||
"type": "tidelift"
|
"type": "tidelift"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2026-05-20T22:57:30+00:00"
|
"time": "2026-06-02T12:23:43+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "guzzlehttp/psr7",
|
"name": "guzzlehttp/psr7",
|
||||||
"version": "2.10.4",
|
"version": "2.11.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/guzzle/psr7.git",
|
"url": "https://github.com/guzzle/psr7.git",
|
||||||
"reference": "d2a1a094e396da8957e797489fddaf860c340cfc"
|
"reference": "bbb5e61349fa5cb822b3e87842b951088b76b81f"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/guzzle/psr7/zipball/d2a1a094e396da8957e797489fddaf860c340cfc",
|
"url": "https://api.github.com/repos/guzzle/psr7/zipball/bbb5e61349fa5cb822b3e87842b951088b76b81f",
|
||||||
"reference": "d2a1a094e396da8957e797489fddaf860c340cfc",
|
"reference": "bbb5e61349fa5cb822b3e87842b951088b76b81f",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^7.2.5 || ^8.0",
|
"php": "^7.2.5 || ^8.0",
|
||||||
"psr/http-factory": "^1.0",
|
"psr/http-factory": "^1.0",
|
||||||
"psr/http-message": "^1.1 || ^2.0",
|
"psr/http-message": "^1.1 || ^2.0",
|
||||||
"ralouphie/getallheaders": "^3.0"
|
"ralouphie/getallheaders": "^3.0",
|
||||||
|
"symfony/deprecation-contracts": "^2.5 || ^3.0",
|
||||||
|
"symfony/polyfill-php80": "^1.24"
|
||||||
},
|
},
|
||||||
"provide": {
|
"provide": {
|
||||||
"psr/http-factory-implementation": "1.0",
|
"psr/http-factory-implementation": "1.0",
|
||||||
@@ -2503,7 +2507,7 @@
|
|||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/guzzle/psr7/issues",
|
"issues": "https://github.com/guzzle/psr7/issues",
|
||||||
"source": "https://github.com/guzzle/psr7/tree/2.10.4"
|
"source": "https://github.com/guzzle/psr7/tree/2.11.0"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
@@ -2519,7 +2523,7 @@
|
|||||||
"type": "tidelift"
|
"type": "tidelift"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2026-05-29T12:59:07+00:00"
|
"time": "2026-06-02T12:30:48+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "guzzlehttp/uri-template",
|
"name": "guzzlehttp/uri-template",
|
||||||
|
|||||||
Reference in new issue
Block a user