wip
This commit is contained in:
1 parent
4f3375f5b3
commit
9686d3b173
3 files changed
+7
-71
No files matched your search
@@ -3,17 +3,12 @@
|
||||
namespace App\Filament\Imports\Helper;
|
||||
|
||||
use App\Models\StatistikoDetail;
|
||||
use App\Traits\UpdateHelper;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\LazyCollection;
|
||||
use Spatie\SimpleExcel\SimpleExcelReader;
|
||||
|
||||
class ImportDetails
|
||||
{
|
||||
use UpdateHelper;
|
||||
|
||||
public static array $player_collection = [];
|
||||
|
||||
public static function run(string $filePath): void
|
||||
{
|
||||
$now = now()->format('Y-m-d H:i:s');
|
||||
@@ -27,25 +22,12 @@ class ImportDetails
|
||||
|
||||
$row = array_values($row);
|
||||
|
||||
// ss_player_id
|
||||
// ss_team_id
|
||||
// tx_team_id
|
||||
// player_name
|
||||
// ss_national_team_id
|
||||
// birthdate
|
||||
// height
|
||||
// nationality
|
||||
// position
|
||||
// preferred_foot
|
||||
// last_update
|
||||
|
||||
if ($row[1] != '') {
|
||||
|
||||
self::$player_collection[] = (int) $row[0];
|
||||
|
||||
StatistikoDetail::upsert(
|
||||
StatistikoDetail::updateOrCreate(
|
||||
[
|
||||
'ss_player_id' => (int) $row[0],
|
||||
],
|
||||
[
|
||||
'ss_team_id' => (int) $row[1],
|
||||
'player_name' => $row[2],
|
||||
'ss_national_team_id' => (int) $row[3],
|
||||
@@ -58,51 +40,13 @@ class ImportDetails
|
||||
'is_active' => 1,
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
],
|
||||
uniqueBy: [
|
||||
'ss_player_id',
|
||||
],
|
||||
update: [
|
||||
'ss_team_id',
|
||||
'player_name',
|
||||
'ss_national_team_id',
|
||||
'birthdate',
|
||||
'height',
|
||||
'nationality',
|
||||
'position',
|
||||
'preferred_foot',
|
||||
'last_update',
|
||||
'is_active',
|
||||
'updated_at',
|
||||
]
|
||||
);
|
||||
// StatistikoDetail::updateOrCreate(
|
||||
// [
|
||||
// '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::whereNotIn('ss_player_id', self::$player_collection)->update(['is_active' => 0, 'ss_team_id' => 0]);
|
||||
StatistikoDetail::where('updated_at', '!=', $now)->update(['is_active' => 0, 'ss_team_id' => 0]);
|
||||
|
||||
/**update statistic player tabel */
|
||||
// UpdateHelper::updatePlayers(1000000);
|
||||
}
|
||||
}
|
||||
@@ -3,14 +3,11 @@
|
||||
namespace App\Filament\Imports\Helper;
|
||||
|
||||
use App\Models\StatistikoPlayer;
|
||||
use App\Traits\UpdateHelper;
|
||||
use Illuminate\Support\LazyCollection;
|
||||
use Spatie\SimpleExcel\SimpleExcelReader;
|
||||
|
||||
class ImportPlayer
|
||||
{
|
||||
use UpdateHelper;
|
||||
|
||||
public static function run(string $filePath): void
|
||||
{
|
||||
$fieldnames = [
|
||||
@@ -115,8 +112,5 @@ class ImportPlayer
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
/**update statistic player tabel */
|
||||
// UpdateHelper::updatePlayers(1000000);
|
||||
}
|
||||
}
|
||||
@@ -257,6 +257,7 @@ class PlayerPropsDrop extends Widget
|
||||
}
|
||||
|
||||
$copystring = '';
|
||||
|
||||
foreach ($this->calculationVariables as $row) {
|
||||
if ($copystring == '') {
|
||||
$keys = array_keys($row);
|
||||
@@ -381,8 +382,6 @@ class PlayerPropsDrop extends Widget
|
||||
|
||||
$results = [];
|
||||
|
||||
$this->calculationVariables = [];
|
||||
|
||||
foreach ($player_totals as $val) {
|
||||
if ($val->details && $val->details->is_active) {
|
||||
|
||||
@@ -499,9 +498,6 @@ class PlayerPropsDrop extends Widget
|
||||
// Considerare la ATR calcolata allo Step 1 (colonna I della Tabella)
|
||||
// Aspettativa per Player: AP = AT * ATR / TOT AT
|
||||
$results[] = $tmp;
|
||||
|
||||
// for dev copy
|
||||
$this->calculationVariables[] = $tmp;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -518,6 +514,8 @@ class PlayerPropsDrop extends Widget
|
||||
}
|
||||
}
|
||||
|
||||
$this->calculationVariables = $results;
|
||||
|
||||
foreach ($this->players as $k => $record) {
|
||||
foreach ($results as $key => $result) {
|
||||
if ((int) $record['id'] == (int) $result['id']) {
|
||||
|
||||
Reference in new issue
Block a user