players cache wip
This commit is contained in:
1 parent
713da3b266
commit
1949a06480
6 files changed
+70
-5
No files matched your search
@@ -4,6 +4,7 @@ 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;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
@@ -16,7 +17,15 @@ class LoadPlayer
|
||||
$team_position = $get('team_position');
|
||||
$sofascore_category_id = $get('sofascore_category_id');
|
||||
$season = $get('season');
|
||||
$season = GetSeason::load($season, $sofascore_category_id);
|
||||
$seasonmode = $get('seasonmode');
|
||||
|
||||
$season = GetSeason::load($season, $seasonmode);
|
||||
|
||||
$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;
|
||||
}
|
||||
|
||||
$matches = StatistikoEvent::whereIn('season', $season)
|
||||
->where(function ($query) use ($team_id, $team_position) {
|
||||
@@ -38,7 +47,6 @@ class LoadPlayer
|
||||
|
||||
$player = SofaScorePlayerPerSeason::with('details')->where('ss_team_id', $team_id)->whereIn('season', $season)->get();
|
||||
|
||||
|
||||
$arr = [];
|
||||
foreach ($player as $val) {
|
||||
if ($val->details) {
|
||||
@@ -108,6 +116,10 @@ class LoadPlayer
|
||||
$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)
|
||||
SofaScorePlayerCache::updateOrCreate(['hash' => $hash], ['players' => $result]);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user