wip
This commit is contained in:
1 parent
d6a13837c5
commit
9cfa60de30
5 files changed
+54
No files matched your search
+1
@@ -21,6 +21,7 @@ class StatistikoImportForm
|
|||||||
'player' => '<span class="text-pink-600">Player History</span>',
|
'player' => '<span class="text-pink-600">Player History</span>',
|
||||||
'fixtures' => '<span class="text-orange-500">Fixtures Upcoming</span>',
|
'fixtures' => '<span class="text-orange-500">Fixtures Upcoming</span>',
|
||||||
'events' => '<span class="text-green-500">Events History</span>',
|
'events' => '<span class="text-green-500">Events History</span>',
|
||||||
|
'teams_tornaments' => '<span class="text-fuchsia-500">Teams in Tornaments</span>',
|
||||||
]),
|
]),
|
||||||
|
|
||||||
FileUpload::make('file_name')
|
FileUpload::make('file_name')
|
||||||
|
|||||||
+2
@@ -32,6 +32,7 @@ class StatistikoImportsTable
|
|||||||
'player' => '<span class="text-pink-600">Player History</span>',
|
'player' => '<span class="text-pink-600">Player History</span>',
|
||||||
'fixtures' => '<span class="text-orange-500">Fixtures Upcoming</span>',
|
'fixtures' => '<span class="text-orange-500">Fixtures Upcoming</span>',
|
||||||
'events' => '<span class="text-green-500">Events History</span>',
|
'events' => '<span class="text-green-500">Events History</span>',
|
||||||
|
'teams_tornaments' => '<span class="text-fuchsia-500">Teams in Tornaments</span>',
|
||||||
]),
|
]),
|
||||||
TextColumn::make('file_name_original')
|
TextColumn::make('file_name_original')
|
||||||
->sortable()
|
->sortable()
|
||||||
@@ -55,6 +56,7 @@ class StatistikoImportsTable
|
|||||||
'events' => 'Events',
|
'events' => 'Events',
|
||||||
'fixtures' => 'Fixtures',
|
'fixtures' => 'Fixtures',
|
||||||
'player' => 'Player',
|
'player' => 'Player',
|
||||||
|
'teams_tornaments' => 'Teams in Tornaments',
|
||||||
]),
|
]),
|
||||||
], layout: FiltersLayout::AboveContent)
|
], layout: FiltersLayout::AboveContent)
|
||||||
->filtersFormColumns(6)
|
->filtersFormColumns(6)
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Imports\Helper;
|
||||||
|
|
||||||
|
use App\Models\SofaScoreRosaTournament;
|
||||||
|
use Illuminate\Support\LazyCollection;
|
||||||
|
use Spatie\SimpleExcel\SimpleExcelReader;
|
||||||
|
|
||||||
|
class ImportTeamsTournaments
|
||||||
|
{
|
||||||
|
public static $active_tournament = [];
|
||||||
|
|
||||||
|
public static function run(string $filePath): void
|
||||||
|
{
|
||||||
|
SofaScoreRosaTournament::query()->update(['in_update' => 0]);
|
||||||
|
|
||||||
|
SimpleExcelReader::create(storage_path('app/public/'.$filePath))
|
||||||
|
->getRows()
|
||||||
|
->chunk(100)
|
||||||
|
->each(function (LazyCollection $chunk) {
|
||||||
|
|
||||||
|
foreach ($chunk as $row) {
|
||||||
|
|
||||||
|
$row = array_values($row);
|
||||||
|
|
||||||
|
self::$active_tournament[] = $row[0];
|
||||||
|
|
||||||
|
dd($row);
|
||||||
|
SofaScoreRosaTournament::updateOrCreate(
|
||||||
|
[
|
||||||
|
'ss_tournament_id' => (int) $row[0],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'ss_team_id' => (int) $row[1],
|
||||||
|
'in_update' => 1,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$tournaments = array_unique(self::$active_tournament);
|
||||||
|
|
||||||
|
SofaScoreRosaTournament::where('in_update', 0)->whereIn('torunament_id', $tournaments)->delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,6 +7,7 @@ use App\Filament\Imports\Helper\ImportDetails;
|
|||||||
use App\Filament\Imports\Helper\ImportEvents;
|
use App\Filament\Imports\Helper\ImportEvents;
|
||||||
use App\Filament\Imports\Helper\ImportFixtures;
|
use App\Filament\Imports\Helper\ImportFixtures;
|
||||||
use App\Filament\Imports\Helper\ImportPlayer;
|
use App\Filament\Imports\Helper\ImportPlayer;
|
||||||
|
use App\Filament\Imports\Helper\ImportTeamsTournaments;
|
||||||
use App\Models\StatistikoImport;
|
use App\Models\StatistikoImport;
|
||||||
|
|
||||||
class StatistikoImporter
|
class StatistikoImporter
|
||||||
@@ -44,6 +45,10 @@ class StatistikoImporter
|
|||||||
case 'player':
|
case 'player':
|
||||||
ImportPlayer::run($filePath);
|
ImportPlayer::run($filePath);
|
||||||
break;
|
break;
|
||||||
|
case 'teams_tornaments':
|
||||||
|
ImportTeamsTournaments::run($filePath);
|
||||||
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
StatistikoImport::query()->where('id', $record->id)->update(['has_run' => 1]);
|
StatistikoImport::query()->where('id', $record->id)->update(['has_run' => 1]);
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ return new class extends Migration
|
|||||||
$table->integer('ss_tournament_id')->default(0)->nullable()->index();
|
$table->integer('ss_tournament_id')->default(0)->nullable()->index();
|
||||||
$table->boolean('disabled')->default(false);
|
$table->boolean('disabled')->default(false);
|
||||||
$table->boolean('grapped')->default(false);
|
$table->boolean('grapped')->default(false);
|
||||||
|
$table->boolean('in_update')->default(false);
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user