This commit is contained in:
salam committed 2026-04-21 14:46:58 +02:00
1 parent 4fa4e1a611
commit e46bda0715
10 files changed
+291 -221

No files matched your search

@@ -0,0 +1,37 @@
<?php
namespace App\Console\Commands;
use App\Models\StatistikoImport;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Storage;
class DeleteUnusedFiles extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'delete:unused-files';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Delete unused statistiko files';
/**
* Execute the console command.
*/
public function handle(): void
{
$tasks = StatistikoImport::pluck('file_name')->toArray();
collect(Storage::disk('public')->allFiles('statistiko'))
->reject(fn (string $file) => $file === '.gitignore')
->reject(fn (string $file) => in_array($file, $tasks))
->each(fn ($file) => Storage::disk('public')->delete($file));
}
}
+3
View File
@@ -12,7 +12,10 @@ class Kernel extends ConsoleKernel
*/
protected function schedule(Schedule $schedule): void
{
$schedule->command('delete:unused-files')->daily();
$schedule->command('model:prune')->daily();
// $schedule->command('inspire')->hourly();
}
@@ -28,6 +28,7 @@ class StatistikoImportForm
FileUpload::make('file_name')
->label('Select File')
->disk('public')
->directory('statistiko')
->visibility('public')
->required()
@@ -69,12 +69,14 @@ class StatistikoImportsTable
->title('Import started')
),
DeleteAction::make()
->successNotificationTitle('File deleted')
->label('Delete file'),
]),
])
->toolbarActions([
BulkActionGroup::make([
DeleteBulkAction::make(),
DeleteBulkAction::make()
->successNotificationTitle('Files deleted'),
]),
]);
}
+36 -9
View File
@@ -88,7 +88,7 @@ class StatistikoImporter
{
$now = now()->format('Y-m-d H:i:s');
SimpleExcelReader::create(storage_path('app/private/'.$filePath))
SimpleExcelReader::create(storage_path('app/public/'.$filePath))
->getRows()
->chunk(1000)
->each(function (LazyCollection $chunk) use ($now) {
@@ -131,7 +131,7 @@ class StatistikoImporter
{
$now = now()->format('Y-m-d H:i:s');
SimpleExcelReader::create(storage_path('app/private/'.$filePath))
SimpleExcelReader::create(storage_path('app/public/'.$filePath))
->getRows()
->chunk(1000)
->each(function (LazyCollection $chunk) use ($now) {
@@ -140,16 +140,43 @@ class StatistikoImporter
foreach ($chunk as $row) {
$row = array_values($row);
dd($row);
// print_r($row);
$row = array_values($row);
// dd($row);
/***
[LEAGUE] => 1
[HOME] => 2133
[AWAY] => 3024
[SS_STARTTIME_VALUE] => DateTimeImmutable Object ( [date] => 2022-08-05 18:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Vienna )
[SS_SEASON_VALUE] => 2022/2023
[GLS_H] => 0
[GLS_A] => 0
[CRN_H] => 3
[CRN_A] => 6
[FLS_H] => 5
[FLS_A] => 8
[OFS_H] => 0
[OFS_A] => 2
[SNT_H] => 2
[SNT_A] => 1
[TSH_H] => 11
[TSH_A] => 13
[CRD_H] => 1
[CRD_A] => 1
[EXPGOALSHOME_VALUE] => 1.6350036183338
[EXPGOALSAWAY_VALUE] => 0.97303070109903
[EXP_HANDICAP] => -0.66197291723478
[EXP_TOTAL] => 2.6080343194328
*/
$data[] = [
'sport_id' => 1,
'league_id' => $row[1],
'home_id' => $row[2],
'away_id' => $row[3],
'starttime' => Carbon::parse($row[4])->toDateTimeString(),
'season' => $row[5],
'league_id' => $row[0],
'home_id' => $row[1],
'away_id' => $row[2],
'starttime' => Carbon::parse($row[3])->toIso8601String(),
'season' => $row[4],
'gls_h' => $row[6],
'gls_a' => $row[7],
'crn_h' => $row[8],
+13
View File
@@ -0,0 +1,13 @@
<?php
use App\Models\StatistikoImport;
use App\Observers\StatistikoImportObserver;
use Illuminate\Support\ServiceProvider;
class EventServiceProvider extends ServiceProvider
{
public function boot(): void
{
StatistikoImport::observe(StatistikoImportObserver::class);
}
}