wip
This commit is contained in:
1 parent
ddc0e03abd
commit
fb19559eff
2 files changed
+1
-76
No files matched your search
@@ -2,11 +2,10 @@
|
|||||||
|
|
||||||
namespace App\Console\Commands;
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use App\Actions\PlayerPerSeason;
|
||||||
use App\Console\Commands\Grapper\Sofascore\Grapper;
|
use App\Console\Commands\Grapper\Sofascore\Grapper;
|
||||||
use App\Console\Commands\Grapper\Sofascore\Helper\MoveToArchive;
|
|
||||||
use App\Console\Commands\Grapper\Sofascore\Helper\SetStorage;
|
use App\Console\Commands\Grapper\Sofascore\Helper\SetStorage;
|
||||||
use App\Console\Commands\Grapper\Sofascore\MakeExcel;
|
use App\Console\Commands\Grapper\Sofascore\MakeExcel;
|
||||||
use App\Console\Commands\Grapper\Sofascore\PlayerPerSeason;
|
|
||||||
use App\Console\Commands\Grapper\Sofascore\Rose;
|
use App\Console\Commands\Grapper\Sofascore\Rose;
|
||||||
use App\Console\Commands\Grapper\Sofascore\SendMail;
|
use App\Console\Commands\Grapper\Sofascore\SendMail;
|
||||||
use App\Console\Commands\Grapper\Sofascore\SettingsToLocal;
|
use App\Console\Commands\Grapper\Sofascore\SettingsToLocal;
|
||||||
|
|||||||
@@ -1,74 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Console\Commands\Grapper\Sofascore;
|
|
||||||
|
|
||||||
use App\Console\Commands\Grap;
|
|
||||||
use App\Models\SofaScorePlayerPerSeason;
|
|
||||||
use App\Models\StatistikoDetail;
|
|
||||||
use App\Models\StatistikoPlayer;
|
|
||||||
use App\Utilities\Notice;
|
|
||||||
|
|
||||||
class PlayerPerSeason
|
|
||||||
{
|
|
||||||
public static function run()
|
|
||||||
{
|
|
||||||
$debug = Grap::$options['d'] ?? 0;
|
|
||||||
|
|
||||||
$res = StatistikoDetail::query()->select('ss_player_id', 'ss_team_id')->get();
|
|
||||||
|
|
||||||
if ($debug) {
|
|
||||||
Notice::note('process ' . $res->count() . " player", 'bb');
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($res as $val) {
|
|
||||||
|
|
||||||
$collection = [];
|
|
||||||
|
|
||||||
$res2 = StatistikoPlayer::with('event')->where('ss_player_id', $val->ss_player_id)->get();
|
|
||||||
|
|
||||||
foreach ($res2 as $val2) {
|
|
||||||
|
|
||||||
if (!isset($collection[$val2->event->season])) {
|
|
||||||
$collection[$val2->event->season]['events_played_home'] = 0;
|
|
||||||
$collection[$val2->event->season]['events_played_away'] = 0;
|
|
||||||
$collection[$val2->event->season]['minutes_played_home'] = 0;
|
|
||||||
$collection[$val2->event->season]['minutes_played_away'] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((int) $val2->minutes_played > 0) {
|
|
||||||
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 ($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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($collection as $season => $row) {
|
|
||||||
if ($val->ss_team_id && $val->ss_player_id) {
|
|
||||||
SofaScorePlayerPerSeason::updateOrCreate(
|
|
||||||
[
|
|
||||||
'ss_player_id' => $val->ss_player_id,
|
|
||||||
'ss_team_id' => $val->ss_team_id,
|
|
||||||
'season' => $season
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'events_played_home' => $row['events_played_home'],
|
|
||||||
'events_played_away' => $row['events_played_away'],
|
|
||||||
'minutes_played_home' => $row['minutes_played_home'],
|
|
||||||
'minutes_played_away' => $row['minutes_played_away'],
|
|
||||||
]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($debug) {
|
|
||||||
Notice::note("done", 'bb');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in new issue
Block a user