This commit is contained in:
salam committed 2026-09-15 07:03:10 +02:00
1 parent 9686d3b173
commit fb85e4cce0
5 files changed
+67 -37

No files matched your search

+29 -28
View File
@@ -11,42 +11,43 @@ class ImportDetails
{ {
public static function run(string $filePath): void public static function run(string $filePath): void
{ {
$now = now()->format('Y-m-d H:i:s'); StatistikoDetail::query()->update(['last_import' => 0]);
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) {
$collection = [];
foreach ($chunk as $row) { foreach ($chunk as $row) {
$row['is_active'] = 1;
$row = array_values($row); $row['last_import'] = 1;
$row['birthdate'] = isset($row['birthday']) ? Carbon::parse($row['birthday'])->format('Y-m-d') : '';
if ($row[1] != '') { unset($row['birthday']);
StatistikoDetail::updateOrCreate( $row['last_update'] = Carbon::parse($row['last_update'])->format('Y-m-d H:i:s');
[ $collection[] = $row;
'ss_player_id' => (int) $row[0],
],
[
'ss_team_id' => (int) $row[1],
'player_name' => $row[2],
'ss_national_team_id' => (int) $row[3],
'birthdate' => Carbon::parse($row[4])->format('Y-m-d'),
'height' => (int) $row[5],
'nationality' => $row[6],
'position' => $row[7],
'preferred_foot' => $row[8],
'last_update' => Carbon::parse($row[9])->format('Y-m-d H:i:s'),
'is_active' => 1,
'created_at' => $now,
'updated_at' => $now,
]
);
}
} }
StatistikoDetail::upsert(
$collection,
uniqueBy: [
'ss_player_id',
],
update: [
'ss_team_id',
'player_name',
'ss_national_team_id',
'birthdate',
'height',
'nationality',
'position',
'preferred_foot',
'last_update',
'is_active',
'last_import',
]);
}); });
StatistikoDetail::where('updated_at', '!=', $now)->update(['is_active' => 0, 'ss_team_id' => 0]); StatistikoDetail::where('last_import', 0)->update(['is_active' => 0, 'ss_team_id' => 0]);
} }
} }
@@ -111,6 +111,34 @@ class ImportPlayer
$update_array $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);
}); });
} }
} }
+3 -1
View File
@@ -506,11 +506,13 @@ class PlayerPropsDrop extends Widget
$bettypes = ['goals', 'cards', 'fouls', 'offsides', 'total_shots', 'shots_on_target']; $bettypes = ['goals', 'cards', 'fouls', 'offsides', 'total_shots', 'shots_on_target'];
foreach ($bettypes as $bettype) { foreach ($bettypes as $bettype) {
$total_bettype = array_sum(array_column($results, 'asp_teorica_'.$bettype)); $total_bettype = array_sum(array_column($results, 'asp_teorica_'.$bettype));
foreach ($results as $key => $value) { foreach ($results as $key => $value) {
// Aspettativa per Player: AP = AT * ATR / TOT AT // Aspettativa per Player: AP = AT * ATR / TOT AT
$results[$key]['asp_total_'.$bettype] = $total_bettype; $results[$key]['asp_total_'.$bettype] = $total_bettype;
// $results[$key]['asp_player_'.$bettype] = ((float) $value['asp_team'] * (float) $value['asp_teorica_'.$bettype]) / $total_bettype; // $results[$key]['asp_player_'.$bettype] = ((float) $value['asp_team'] * (float) $value['asp_teorica_'.$bettype]) / $total_bettype;
$results[$key]['asp_player_'.$bettype] = ($asp_team * $asp_team_riferimento) / $total_bettype; // $results[$key]['asp_player_'.$bettype] = ($asp_team * $asp_team_riferimento) / $total_bettype;
$results[$key]['asp_player_'.$bettype] = ($value['asp_teorica_'.$bettype] * $asp_team_riferimento) / $total_bettype;
} }
} }
+1 -2
View File
@@ -24,9 +24,8 @@ class StatistikoDetail extends Model
'position', 'position',
'preferred_foot', 'preferred_foot',
'last_update', 'last_update',
'last_import',
'is_active', 'is_active',
'created_at',
'updated_at',
]; ];
protected $casts = [ protected $casts = [
Generated
+6 -6
View File
@@ -4098,16 +4098,16 @@
}, },
{ {
"name": "livewire/livewire", "name": "livewire/livewire",
"version": "v4.4.4", "version": "v4.4.5",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/livewire/livewire.git", "url": "https://github.com/livewire/livewire.git",
"reference": "00bf1b9959807d7cbcf38fc088515a7261cb6fa8" "reference": "10aa0b5ee44c99b5bce0f78ad265bbcf0e74abdc"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/livewire/livewire/zipball/00bf1b9959807d7cbcf38fc088515a7261cb6fa8", "url": "https://api.github.com/repos/livewire/livewire/zipball/10aa0b5ee44c99b5bce0f78ad265bbcf0e74abdc",
"reference": "00bf1b9959807d7cbcf38fc088515a7261cb6fa8", "reference": "10aa0b5ee44c99b5bce0f78ad265bbcf0e74abdc",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -4162,7 +4162,7 @@
"description": "A front-end framework for Laravel.", "description": "A front-end framework for Laravel.",
"support": { "support": {
"issues": "https://github.com/livewire/livewire/issues", "issues": "https://github.com/livewire/livewire/issues",
"source": "https://github.com/livewire/livewire/tree/v4.4.4" "source": "https://github.com/livewire/livewire/tree/v4.4.5"
}, },
"funding": [ "funding": [
{ {
@@ -4170,7 +4170,7 @@
"type": "github" "type": "github"
} }
], ],
"time": "2026-09-07T16:02:43+00:00" "time": "2026-09-14T19:27:16+00:00"
}, },
{ {
"name": "maennchen/zipstream-php", "name": "maennchen/zipstream-php",