fix update player
This commit is contained in:
1 parent
e3f1e8a8d9
commit
f028a8b2a8
16 files changed
+605
-224
No files matched your search
@@ -2,14 +2,16 @@
|
||||
|
||||
namespace App\Filament\Imports\Helper;
|
||||
|
||||
use App\Actions\PlayerPerSeason;
|
||||
use App\Models\StatistikoDetail;
|
||||
use App\Traits\UpdatePlayerSeasonHelper;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\LazyCollection;
|
||||
use Spatie\SimpleExcel\SimpleExcelReader;
|
||||
|
||||
class ImportDetails
|
||||
{
|
||||
use UpdatePlayerSeasonHelper;
|
||||
|
||||
public static function run(string $filePath): void
|
||||
{
|
||||
$now = now()->format('Y-m-d H:i:s');
|
||||
@@ -62,6 +64,6 @@ class ImportDetails
|
||||
StatistikoDetail::where('updated_at', '!=', $now)->update(['is_active' => 0]);
|
||||
|
||||
/**update statistic player tabel */
|
||||
PlayerPerSeason::run();
|
||||
UpdatePlayerSeasonHelper::update(1000000);
|
||||
}
|
||||
}
|
||||
@@ -2,13 +2,15 @@
|
||||
|
||||
namespace App\Filament\Imports\Helper;
|
||||
|
||||
use App\Actions\PlayerPerSeason;
|
||||
use App\Models\StatistikoPlayer;
|
||||
use App\Traits\UpdatePlayerSeasonHelper;
|
||||
use Illuminate\Support\LazyCollection;
|
||||
use Spatie\SimpleExcel\SimpleExcelReader;
|
||||
|
||||
class ImportPlayer
|
||||
{
|
||||
use UpdatePlayerSeasonHelper;
|
||||
|
||||
public static function run(string $filePath): void
|
||||
{
|
||||
$fieldnames = [
|
||||
@@ -78,10 +80,10 @@ class ImportPlayer
|
||||
'penaltyshoutout_missed',
|
||||
'player_position',
|
||||
'playerrating_value',
|
||||
'tm_player_id'
|
||||
'tm_player_id',
|
||||
];
|
||||
|
||||
SimpleExcelReader::create(storage_path('app/public/' . $filePath))
|
||||
SimpleExcelReader::create(storage_path('app/public/'.$filePath))
|
||||
->getRows()
|
||||
->chunk(1000)
|
||||
->each(function (LazyCollection $chunk) use ($fieldnames) {
|
||||
@@ -95,12 +97,13 @@ class ImportPlayer
|
||||
|
||||
$update_array = [];
|
||||
foreach ($fieldnames as $key => $name) {
|
||||
if ($key == 1)
|
||||
if ($key == 1) {
|
||||
$match_id = (int) $row[$key];
|
||||
else if ($key == 2)
|
||||
} elseif ($key == 2) {
|
||||
$ss_player_id = (int) $row[$key];
|
||||
else
|
||||
} else {
|
||||
$update_array[$name] = $row[$key];
|
||||
}
|
||||
}
|
||||
|
||||
StatistikoPlayer::updateOrCreate(
|
||||
@@ -114,6 +117,6 @@ class ImportPlayer
|
||||
});
|
||||
|
||||
/**update statistic player tabel */
|
||||
PlayerPerSeason::run();
|
||||
UpdatePlayerSeasonHelper::update(1000000);
|
||||
}
|
||||
}
|
||||
+21
-23
@@ -3,21 +3,20 @@
|
||||
namespace App\Filament\Pages\Selections;
|
||||
|
||||
use App\Filament\Pages\Selections\Helper\GetSeason;
|
||||
use App\Filament\Pages\Selections\LoadPositions;
|
||||
use App\Models\SofaScorePlayerCache;
|
||||
use App\Models\SofaScorePlayerPerSeason;
|
||||
use App\Models\StatistikoEvent;
|
||||
|
||||
class LoadPlayer
|
||||
class LoadPlayerSelection
|
||||
{
|
||||
public static function load(int|null $team_id, string|null $team_position, int|null $sofascore_category_id, array|null $season, string|null $seasonmode)
|
||||
public static function load(?int $team_id, ?string $team_position, ?int $sofascore_category_id, ?array $season, ?string $seasonmode)
|
||||
{
|
||||
$season = GetSeason::load($season, $seasonmode);
|
||||
|
||||
$hash = hash('crc32', $team_id . $team_position . $sofascore_category_id . serialize($season));
|
||||
$hash = hash('crc32', $team_id.$team_position.$sofascore_category_id.serialize($season));
|
||||
$cached_players = SofaScorePlayerCache::where('hash', $hash)->value('players');
|
||||
if ($cached_players) {
|
||||
// return $cached_players;
|
||||
return $cached_players;
|
||||
}
|
||||
|
||||
$matches = StatistikoEvent::whereIn('season', $season)
|
||||
@@ -33,7 +32,6 @@ class LoadPlayer
|
||||
}
|
||||
})->pluck('match_id')->toArray();
|
||||
|
||||
|
||||
$matches_count = count($matches);
|
||||
|
||||
$positions_map = LoadPositions::load();
|
||||
@@ -44,7 +42,7 @@ class LoadPlayer
|
||||
foreach ($player as $val) {
|
||||
if ($val->details) {
|
||||
$player_id = $val->ss_player_id;
|
||||
if (!isset($arr[$player_id])) {
|
||||
if (! isset($arr[$player_id])) {
|
||||
$arr[$player_id]['player_name'] = $val->details->player_name;
|
||||
$arr[$player_id]['events_played_home'] = $val->events_played_home;
|
||||
$arr[$player_id]['events_played_away'] = $val->events_played_away;
|
||||
@@ -80,43 +78,43 @@ class LoadPlayer
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
$colorlevel = round($matches_count / 3);
|
||||
|
||||
if (in_array($val['player_position'], $positions_map['MIDFIELD'])) {
|
||||
$position = 'MIDFIELD';
|
||||
} else if (in_array($val['player_position'], $positions_map['DEFENCE'])) {
|
||||
} elseif (in_array($val['player_position'], $positions_map['DEFENCE'])) {
|
||||
$position = 'DEFENCE';
|
||||
} else if (in_array($val['player_position'], $positions_map['ATTACK'])) {
|
||||
} elseif (in_array($val['player_position'], $positions_map['ATTACK'])) {
|
||||
$position = 'ATTACK';
|
||||
} else if (in_array($val['player_position'], $positions_map['GOALKEEPER'])) {
|
||||
} elseif (in_array($val['player_position'], $positions_map['GOALKEEPER'])) {
|
||||
$position = 'GOALKEEPER';
|
||||
} else {
|
||||
$position = 'NO SPECIFIC POSITION';
|
||||
}
|
||||
|
||||
$infostring = $events_played . ' Ev';
|
||||
if ($val['preferred_foot'])
|
||||
$infostring .= ' - ' . $val['preferred_foot'];
|
||||
if ($events_played)
|
||||
$infostring .= ' - ' . round($minues_played / $events_played) . 'min';
|
||||
$infostring = $events_played.' Ev';
|
||||
if ($val['preferred_foot']) {
|
||||
$infostring .= ' - '.$val['preferred_foot'];
|
||||
}
|
||||
if ($events_played) {
|
||||
$infostring .= ' - '.round($minues_played / $events_played).'min';
|
||||
}
|
||||
if ($colorlevel > 1 && $events_played < $colorlevel) {
|
||||
$result[$position][$player_id] = '<span class="text-red-600 dark:text-red-500 cursor-pointer"><b>' . $val['player_name'] . '</b> ' . $position . '<br>' . $infostring . '</span>';
|
||||
} else if ($events_played < $colorlevel * 2) {
|
||||
$result[$position][$player_id] = '<span class="text-blue-600 dark:text-blue-500 cursor-pointer"><b>' . $val['player_name'] . '</b> ' . $position . '<br>' . $infostring . '</span>';
|
||||
$result[$position][$player_id] = '<span class="text-red-600 dark:text-red-500 cursor-pointer"><b>'.$val['player_name'].'</b> '.$position.'<br>'.$infostring.'</span>';
|
||||
} elseif ($events_played < $colorlevel * 2) {
|
||||
$result[$position][$player_id] = '<span class="text-blue-600 dark:text-blue-500 cursor-pointer"><b>'.$val['player_name'].'</b> '.$position.'<br>'.$infostring.'</span>';
|
||||
} else {
|
||||
$result[$position][$player_id] = '<span class="text-green-600 dark:text-green-500 cursor-pointer"><b>' . $val['player_name'] . '</b> ' . $position . '<br>' . $infostring . '</span>';
|
||||
$result[$position][$player_id] = '<span class="text-green-600 dark:text-green-500 cursor-pointer"><b>'.$val['player_name'].'</b> '.$position.'<br>'.$infostring.'</span>';
|
||||
}
|
||||
}
|
||||
|
||||
if ($result)
|
||||
if ($result) {
|
||||
SofaScorePlayerCache::updateOrCreate(['hash' => $hash], ['players' => $result]);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static function convertToHoursMins(int $time, $format = '%02dh:%02dm')
|
||||
{
|
||||
if ($time < 1) {
|
||||
@@ -5,7 +5,7 @@ namespace App\Filament\Pages;
|
||||
use App\Actions\LoadSofaScoreCategory;
|
||||
use App\Actions\LoadStatisticFixturesLeaguesOptions;
|
||||
use App\Actions\LoadStatisticFixturesMatchOptions;
|
||||
use App\Filament\Pages\Selections\LoadPlayer;
|
||||
use App\Filament\Pages\Selections\LoadPlayerSelection;
|
||||
use App\Models\SofaScoreCategory;
|
||||
use App\Models\SofaScoreRosa;
|
||||
use App\Models\StatisticFixtures;
|
||||
@@ -347,7 +347,7 @@ class Statistic extends BaseDashboard
|
||||
$season = $get('season');
|
||||
$seasonmode = $get('seasonmode');
|
||||
|
||||
return LoadPlayer::load($team_id, $team_position, $sofascore_category_id, $season, $seasonmode);
|
||||
return LoadPlayerSelection::load($team_id, $team_position, $sofascore_category_id, $season, $seasonmode);
|
||||
}),
|
||||
Select::make('player_on_field')
|
||||
->live()
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace App\Filament\Widgets;
|
||||
|
||||
use App\Filament\Widgets\Data\HelperStatisticType;
|
||||
use App\Filament\Widgets\Data\LoadPlayer;
|
||||
use App\Filament\Widgets\Data\LoadPlayerWidgets;
|
||||
use Filament\Support\RawJs;
|
||||
use Filament\Widgets\ChartWidget;
|
||||
use Illuminate\Support\HtmlString;
|
||||
@@ -38,16 +38,16 @@ class ChartPlayer extends ChartWidget
|
||||
c0.211,0.1782,0.5264,0.1516,0.7046-0.0593C13.0037,6.5523,13.0018,6.2761,12.84,6.09z"></path>
|
||||
</g>
|
||||
</svg>
|
||||
' . $this->player . '
|
||||
'.$this->player.'
|
||||
</span>
|
||||
<span>' . $this->type . '</span>
|
||||
<span>'.$this->type.'</span>
|
||||
</span>
|
||||
');
|
||||
}
|
||||
|
||||
protected function getData(): array
|
||||
{
|
||||
$data = LoadPlayer::load($this->filters, true);
|
||||
$data = LoadPlayerWidgets::load($this->filters, true);
|
||||
|
||||
if ($data) {
|
||||
$this->player = $data['player_name'] ?? '';
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace App\Filament\Widgets;
|
||||
|
||||
use App\Filament\Widgets\Data\HelperMoveingAverage;
|
||||
use App\Filament\Widgets\Data\HelperStatisticType;
|
||||
use App\Filament\Widgets\Data\LoadPlayer;
|
||||
use App\Filament\Widgets\Data\LoadPlayerWidgets;
|
||||
use Filament\Support\RawJs;
|
||||
use Filament\Widgets\ChartWidget;
|
||||
use Illuminate\Support\HtmlString;
|
||||
@@ -39,16 +39,16 @@ class ChartPlayerMoAv extends ChartWidget
|
||||
c0.211,0.1782,0.5264,0.1516,0.7046-0.0593C13.0037,6.5523,13.0018,6.2761,12.84,6.09z"></path>
|
||||
</g>
|
||||
</svg>
|
||||
' . $this->player . '
|
||||
'.$this->player.'
|
||||
</span>
|
||||
<span>' . $this->type . ' Moving Average</span>
|
||||
<span>'.$this->type.' Moving Average</span>
|
||||
</span>
|
||||
');
|
||||
}
|
||||
|
||||
protected function getData(): array
|
||||
{
|
||||
$data = LoadPlayer::load($this->filters, false);
|
||||
$data = LoadPlayerWidgets::load($this->filters, false);
|
||||
|
||||
if ($data) {
|
||||
$this->player = $data['player_name'] ?? '';
|
||||
|
||||
+2
-7
@@ -8,7 +8,7 @@ use App\Models\StatistikoEvent;
|
||||
use App\Models\StatistikoPlayer;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
class LoadPlayer
|
||||
class LoadPlayerWidgets
|
||||
{
|
||||
public static $last_query = [];
|
||||
|
||||
@@ -29,7 +29,6 @@ class LoadPlayer
|
||||
|
||||
$player_on_field = $filter['player_on_field'] ?? 'all';
|
||||
|
||||
|
||||
$season = $filter['season'];
|
||||
$seasonmode = $filter['seasonmode'];
|
||||
$season = GetSeason::load($season, $seasonmode);
|
||||
@@ -110,7 +109,7 @@ class LoadPlayer
|
||||
|
||||
if (isset($value->event->starttime)) {
|
||||
|
||||
$key = round($value->event->starttime->diffInDays(Carbon::now()));
|
||||
$key = (int) round($value->event->starttime->diffInDays(Carbon::now()));
|
||||
|
||||
switch ($statistic_type) {
|
||||
case 'gls':
|
||||
@@ -140,8 +139,6 @@ class LoadPlayer
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
krsort($tmp);
|
||||
$dataset = [];
|
||||
$labels = [];
|
||||
@@ -153,8 +150,6 @@ class LoadPlayer
|
||||
$avverage = array_sum($dataset) / count($dataset);
|
||||
$dataset2 = array_fill(0, count($dataset), $avverage);
|
||||
|
||||
|
||||
|
||||
$data = [
|
||||
'datasets' => [
|
||||
[
|
||||
Reference in new issue
Block a user