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

No files matched your search

+28 -27
View File
@@ -11,42 +11,43 @@ class ImportDetails
{
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))
->getRows()
->chunk(1000)
->each(function (LazyCollection $chunk) use ($now) {
->each(function (LazyCollection $chunk) {
$collection = [];
foreach ($chunk as $row) {
$row['is_active'] = 1;
$row['last_import'] = 1;
$row['birthdate'] = isset($row['birthday']) ? Carbon::parse($row['birthday'])->format('Y-m-d') : '';
unset($row['birthday']);
$row['last_update'] = Carbon::parse($row['last_update'])->format('Y-m-d H:i:s');
$collection[] = $row;
}
$row = array_values($row);
if ($row[1] != '') {
StatistikoDetail::updateOrCreate(
[
'ss_player_id' => (int) $row[0],
StatistikoDetail::upsert(
$collection,
uniqueBy: [
'ss_player_id',
],
[
'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,
]
);
}
}
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
);
}
// $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'];
foreach ($bettypes as $bettype) {
$total_bettype = array_sum(array_column($results, 'asp_teorica_'.$bettype));
foreach ($results as $key => $value) {
// Aspettativa per Player: AP = AT * ATR / TOT AT
$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] = ($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',
'preferred_foot',
'last_update',
'last_import',
'is_active',
'created_at',
'updated_at',
];
protected $casts = [
Generated
+6 -6
View File
@@ -4098,16 +4098,16 @@
},
{
"name": "livewire/livewire",
"version": "v4.4.4",
"version": "v4.4.5",
"source": {
"type": "git",
"url": "https://github.com/livewire/livewire.git",
"reference": "00bf1b9959807d7cbcf38fc088515a7261cb6fa8"
"reference": "10aa0b5ee44c99b5bce0f78ad265bbcf0e74abdc"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/livewire/livewire/zipball/00bf1b9959807d7cbcf38fc088515a7261cb6fa8",
"reference": "00bf1b9959807d7cbcf38fc088515a7261cb6fa8",
"url": "https://api.github.com/repos/livewire/livewire/zipball/10aa0b5ee44c99b5bce0f78ad265bbcf0e74abdc",
"reference": "10aa0b5ee44c99b5bce0f78ad265bbcf0e74abdc",
"shasum": ""
},
"require": {
@@ -4162,7 +4162,7 @@
"description": "A front-end framework for Laravel.",
"support": {
"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": [
{
@@ -4170,7 +4170,7 @@
"type": "github"
}
],
"time": "2026-09-07T16:02:43+00:00"
"time": "2026-09-14T19:27:16+00:00"
},
{
"name": "maennchen/zipstream-php",