wip
This commit is contained in:
1 parent
c394f7afba
commit
44af3f2caa
21 files changed
+222
-151
No files matched your search
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Actions;
|
||||
|
||||
use App\Models\CompetitionGroup;
|
||||
use App\Models\SofaScoreTournament;
|
||||
use App\Models\StatisticFixtures;
|
||||
|
||||
class LoadStatisticFixturesLeaguesOptions
|
||||
@@ -13,10 +13,10 @@ class LoadStatisticFixturesLeaguesOptions
|
||||
->groupBy('league_id')
|
||||
->pluck('league_id')->toArray();
|
||||
|
||||
$cnt = CompetitionGroup::with('country')->whereIn('id', $res)->get();
|
||||
$cnt = SofaScoreTournament::with('sofascore_category')->whereIn('tournament_id', $res)->get();
|
||||
$arr = [];
|
||||
foreach ($cnt as $val) {
|
||||
$arr[$val->id] = $val->country->name . ' ' . $val->name;
|
||||
$arr[$val->tournament_id] = $val->sofascore_category->name . ' ' . $val->name;
|
||||
}
|
||||
|
||||
asort($arr);
|
||||
|
||||
@@ -6,7 +6,7 @@ use App\Models\StatisticFixtures;
|
||||
|
||||
class LoadStatisticFixturesMatchOptions
|
||||
{
|
||||
public static function load($league_id)
|
||||
public static function load(int $league_id)
|
||||
{
|
||||
if (! $league_id) {
|
||||
return [];
|
||||
@@ -15,7 +15,7 @@ class LoadStatisticFixturesMatchOptions
|
||||
|
||||
$arr = [];
|
||||
foreach ($res as $val) {
|
||||
$arr[$val->id] = $val->starttime->format('Y-m-d H:i') . ' - ' . $val->home->name . ' vs ' . $val->away->name;
|
||||
$arr[$val->id] = $val->starttime->format('Y-m-d H:i') . ' - ' . $val->home->ss_team_name . ' vs ' . $val->away->ss_team_name;
|
||||
}
|
||||
|
||||
return $arr;
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Actions\Selections;
|
||||
|
||||
use App\Models\SofaScorePlayerPerSeason;
|
||||
use App\Models\SofaScorePlayerPosition;
|
||||
use App\Models\StatistikoEvent;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
|
||||
@@ -17,6 +18,7 @@ class LoadPlayer
|
||||
$team_position = $get('team_position');
|
||||
|
||||
$season_or_date = $filter['season_or_date'] ?? 'season';
|
||||
|
||||
if ($season_or_date != 'season' or !count($season)) {
|
||||
$season[] = date('Y');
|
||||
}
|
||||
@@ -35,8 +37,10 @@ class LoadPlayer
|
||||
|
||||
$matches_count = count($matches);
|
||||
|
||||
$ss_positions_map = SofaScorePlayerPosition::pluck('name', 'ss_code')->toArray();
|
||||
|
||||
// needs to run daily for pre-calculaton
|
||||
$player = SofaScorePlayerPerSeason::with('details')->where('tx_team_id', $team_id)->whereIn('season', $season)->get();
|
||||
$player = SofaScorePlayerPerSeason::with('details')->where('ss_team_id', $team_id)->whereIn('season', $season)->get();
|
||||
|
||||
$arr = [];
|
||||
foreach ($player as $val) {
|
||||
@@ -44,25 +48,31 @@ class LoadPlayer
|
||||
switch ($team_position) {
|
||||
case 'home':
|
||||
$events_played = $val->events_played_home;
|
||||
$minues_played = $val->minutes_played_home;
|
||||
break;
|
||||
case 'away':
|
||||
$events_played = $val->events_played_away;
|
||||
$minues_played = $val->minutes_played_away;
|
||||
break;
|
||||
default:
|
||||
$events_played = $val->events_played_home + $val->events_played_away;
|
||||
$minues_played = $val->minutes_played_home + $val->minutes_played_home;
|
||||
break;
|
||||
}
|
||||
|
||||
$colorlevel = round($matches_count / 3);
|
||||
|
||||
$position = strtoupper($val->details->position);
|
||||
$time_played = round($minues_played / 60) . ':';
|
||||
$time_played .= $minues_played % 60;
|
||||
|
||||
$position = $ss_positions_map[$val->details->position] ?? 'No Specific Position';
|
||||
|
||||
if ($events_played < $colorlevel) {
|
||||
$arr[$position][$val->ss_player_id] = '<span class="text-red-600 dark:text-red-500">' . $val->details->name . ' (' . $events_played . ')</span>';
|
||||
$arr[$position][$val->ss_player_id] = '<span class="text-red-600 dark:text-red-500">' . $val->details->player_name . '(' . $events_played . ') (' . $time_played . ')</span>';
|
||||
} else if ($events_played < $colorlevel * 2) {
|
||||
$arr[$position][$val->ss_player_id] = '<span class="text-blue-600 dark:text-blue-500">' . $val->details->name . ' (' . $events_played . ')</span>';
|
||||
$arr[$position][$val->ss_player_id] = '<span class="text-blue-600 dark:text-blue-500">' . $val->details->player_name . ' (' . $events_played . ') (' . $time_played . '';
|
||||
} else {
|
||||
$arr[$position][$val->ss_player_id] = '<span class="text-green-600 dark:text-green-500">' . $val->details->name . ' (' . $events_played . ')</span>';
|
||||
$arr[$position][$val->ss_player_id] = '<span class="text-green-600 dark:text-green-500">' . $val->details->player_name . ' (' . $events_played . ') (' . $time_played . ')</span>';
|
||||
}
|
||||
}
|
||||
return $arr;
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Selections;
|
||||
|
||||
use App\Models\SofaScorePlayerPosition;
|
||||
|
||||
class LoadPosition
|
||||
{
|
||||
public static function load()
|
||||
{
|
||||
$res = SofaScorePlayerPosition::get();
|
||||
|
||||
$arr = [];
|
||||
foreach ($res as $val) {
|
||||
$arr[$val->ss_code] = $val->season;
|
||||
}
|
||||
|
||||
return $arr;
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ use App\Models\StatistikoEvent;
|
||||
|
||||
class LoadSeasons
|
||||
{
|
||||
public static function load($league_id)
|
||||
public static function load(int $league_id)
|
||||
{
|
||||
// $res = CompetitionGroup::with('country')->where('id', $league_id)->first();
|
||||
// $season_mode = $res->country->season_mode;
|
||||
|
||||
@@ -14,7 +14,7 @@ class PlayerPerSeason
|
||||
{
|
||||
$debug = Nuh::$options['d'] ?? 0;
|
||||
|
||||
$res = StatistikoDetail::query()->select('ss_player_id', 'txodds_id')->get();
|
||||
$res = StatistikoDetail::query()->select('ss_player_id', 'ss_team_id')->get();
|
||||
|
||||
if ($debug) {
|
||||
Notice::note('process ' . $res->count() . " player", 'bb');
|
||||
@@ -35,10 +35,12 @@ class PlayerPerSeason
|
||||
$collection[$val2->event->season]['minutes_played_away'] = 0;
|
||||
}
|
||||
if ($val2->minutes_played > 0) {
|
||||
if ($val->txodds_id == $val2->event->home_id) {
|
||||
if ($val2->activeteam_id == $val2->event->home_id) {
|
||||
|
||||
$collection[$val2->event->season]['events_played_home'] += 1;
|
||||
$collection[$val2->event->season]['minutes_played_home'] += $val2->minutes_played;
|
||||
} else if ($val->txodds_id == $val2->event->away_id) {
|
||||
} else if ($val2->activeteam_id == $val2->event->away_id) {
|
||||
|
||||
$collection[$val2->event->season]['events_played_away'] += 1;
|
||||
$collection[$val2->event->season]['minutes_played_away'] += $val2->minutes_played;
|
||||
}
|
||||
@@ -46,11 +48,11 @@ class PlayerPerSeason
|
||||
}
|
||||
|
||||
foreach ($collection as $season => $row) {
|
||||
if ($val->txodds_id && $val->ss_player_id) {
|
||||
if ($val->ss_team_id && $val->ss_player_id) {
|
||||
SofaScorePlayerPerSeason::updateOrCreate(
|
||||
[
|
||||
'ss_player_id' => $val->ss_player_id,
|
||||
'tx_team_id' => $val->txodds_id,
|
||||
'ss_team_id' => $val->ss_team_id,
|
||||
'season' => $season
|
||||
],
|
||||
[
|
||||
|
||||
+3
-3
@@ -18,14 +18,14 @@ class StatistikoDetailForm
|
||||
'xl' => 4,
|
||||
])->schema([
|
||||
TextInput::make('ss_player_id')->required(),
|
||||
TextInput::make('ss_team_id')->required(),
|
||||
TextInput::make('tx_team_id'),
|
||||
TextInput::make('player_name')->required(),
|
||||
DatePicker::make('ss_national_team_id'),
|
||||
DatePicker::make('birthdate'),
|
||||
TextInput::make('height'),
|
||||
TextInput::make('nationality'),
|
||||
TextInput::make('position'),
|
||||
TextInput::make('ss_national_team_id'),
|
||||
TextInput::make('tx_team_id'),
|
||||
TextInput::make('team_name'),
|
||||
TextInput::make('preferred_foot'),
|
||||
DatePicker::make('last_update'),
|
||||
]),
|
||||
|
||||
-1
@@ -19,7 +19,6 @@ class StatistikoPlayerForm
|
||||
TextInput::make('sport_id'),
|
||||
TextInput::make('match_id'),
|
||||
TextInput::make('ss_player_id'),
|
||||
TextInput::make('ss_player_id'),
|
||||
TextInput::make('activeteam_id'),
|
||||
TextInput::make('playersubstitute_id'),
|
||||
TextInput::make('goals'),
|
||||
|
||||
+2
-3
@@ -21,12 +21,11 @@ class StatistikoPlayersTable
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('match_id')->searchable(),
|
||||
TextColumn::make('details.name')
|
||||
TextColumn::make('ss_player_id')->label('SofaScore Id')->searchable(),
|
||||
TextColumn::make('details.player_name')
|
||||
->label('Player')
|
||||
->searchable()
|
||||
->tooltip(fn($record) => $record->details->full_name),
|
||||
TextColumn::make('ss_player_id')->label('TM Id')->searchable(),
|
||||
TextColumn::make('ss_player_id')->label('SS Id')->searchable(),
|
||||
TextColumn::make('event.home.name')->searchable()->color('primary'),
|
||||
TextColumn::make('event.away.name')->searchable()->color('success'),
|
||||
])
|
||||
|
||||
@@ -23,6 +23,7 @@ class ImportDetails
|
||||
$row = array_values($row);
|
||||
|
||||
// ss_player_id
|
||||
//
|
||||
// ss_team_id
|
||||
// tx_team_id
|
||||
// player_name
|
||||
|
||||
@@ -77,7 +77,7 @@ class ImportPlayer
|
||||
'penaltyshoutout_missed',
|
||||
'player_position',
|
||||
'playerrating_value',
|
||||
'ss_player_id'
|
||||
'tm_player_id'
|
||||
];
|
||||
|
||||
SimpleExcelReader::create(storage_path('app/public/' . $filePath))
|
||||
@@ -89,15 +89,12 @@ class ImportPlayer
|
||||
|
||||
$row = array_values($row);
|
||||
|
||||
$sport_id = 1;
|
||||
$match_id = 0;
|
||||
$ss_player_id = 0;
|
||||
|
||||
$update_array = [];
|
||||
foreach ($fieldnames as $key => $name) {
|
||||
if ($key == 0)
|
||||
$sport_id = (int) $row[$key];
|
||||
else if ($key == 1)
|
||||
if ($key == 1)
|
||||
$match_id = (int) $row[$key];
|
||||
else if ($key == 2)
|
||||
$ss_player_id = (int) $row[$key];
|
||||
@@ -107,7 +104,6 @@ class ImportPlayer
|
||||
|
||||
StatistikoPlayer::updateOrCreate(
|
||||
[
|
||||
'sport_id' => $sport_id,
|
||||
'match_id' => $match_id,
|
||||
'ss_player_id' => $ss_player_id,
|
||||
],
|
||||
|
||||
@@ -7,6 +7,7 @@ use App\Actions\LoadStatisticFixturesMatchOptions;
|
||||
use App\Actions\Selections\LoadPlayer;
|
||||
use App\Actions\Selections\LoadSeasons;
|
||||
use App\Models\Element;
|
||||
use App\Models\SofaScoreRosa;
|
||||
use App\Models\StatisticFixtures;
|
||||
use BackedEnum;
|
||||
use BezhanSalleh\FilamentShield\Traits\HasPageShield;
|
||||
@@ -108,9 +109,12 @@ class Statistic extends BaseDashboard
|
||||
if ($get('match_id')) {
|
||||
$res = StatisticFixtures::where('id', $get('match_id'))->first();
|
||||
|
||||
|
||||
$arr = [];
|
||||
$arr[$res->home_id] = Element::query()->where('id', $res->home_id)->value('name');
|
||||
$arr[$res->away_id] = Element::query()->where('id', $res->away_id)->value('name');
|
||||
if ($res) {
|
||||
$arr[$res->home_id] = SofaScoreRosa::query()->where('ss_team_id', $res->home_id)->value('ss_team_name');
|
||||
$arr[$res->away_id] = SofaScoreRosa::query()->where('ss_team_id', $res->away_id)->value('ss_team_name');
|
||||
}
|
||||
|
||||
return $arr;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@ class LoadPerformance
|
||||
|
||||
public static function load(array $filter, bool $hasdots)
|
||||
{
|
||||
// dd($filter);
|
||||
|
||||
$league_id = (int) $filter['league_id'] ?? 0;
|
||||
|
||||
@@ -34,8 +33,12 @@ class LoadPerformance
|
||||
|
||||
$match = StatisticFixtures::with('home')->with('away')->where('id', $match_id)->first();
|
||||
|
||||
$home_id = $match->home_id;
|
||||
$away_id = $match->away_id;
|
||||
if (! $match) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$home_id = $match->home_id ?? 0;
|
||||
$away_id = $match->away_id ?? 0;
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ class LoadPlayer
|
||||
$statistic_type = 'gls';
|
||||
}
|
||||
|
||||
$player_name = StatistikoDetail::where('ss_player_id', (int) $ss_player_id)->value('name');
|
||||
$player_name = StatistikoDetail::where('ss_player_id', (int) $ss_player_id)->value('player_name');
|
||||
|
||||
$res = StatistikoPlayer::with('event')->where('ss_player_id', (int) $ss_player_id)->get();
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class RosaTournament extends Model
|
||||
{
|
||||
//
|
||||
}
|
||||
@@ -8,7 +8,7 @@ class SofaScorePlayerPerSeason extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'ss_player_id',
|
||||
'tx_team_id',
|
||||
'ss_team_id',
|
||||
'season',
|
||||
'events_played_home',
|
||||
'events_played_away',
|
||||
|
||||
@@ -35,11 +35,11 @@ class StatisticFixtures extends Model
|
||||
|
||||
public function home()
|
||||
{
|
||||
return $this->belongsTo(Element::class);
|
||||
return $this->belongsTo(SofaScoreRosa::class, 'home_id', 'ss_team_id');
|
||||
}
|
||||
|
||||
public function away()
|
||||
{
|
||||
return $this->belongsTo(Element::class);
|
||||
return $this->belongsTo(SofaScoreRosa::class, 'away_id', 'ss_team_id');
|
||||
}
|
||||
}
|
||||
@@ -80,6 +80,6 @@ class StatistikoPlayer extends Model
|
||||
|
||||
public function details()
|
||||
{
|
||||
return $this->belongsTo(StatistikoDetail::class, 'tm_player_id', 'tm_player_id');
|
||||
return $this->belongsTo(StatistikoDetail::class, 'ss_player_id', 'ss_player_id');
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user