move all to ss IDs
This commit is contained in:
1 parent
09bf62c525
commit
df0a2a9de0
24 files changed
+527
-101
No files matched your search
@@ -62,15 +62,15 @@ class LoadPlayer
|
||||
|
||||
$colorlevel = round($matches_count / 3);
|
||||
|
||||
$time_played = round($minues_played / 60) . ':';
|
||||
$time_played .= $minues_played % 60;
|
||||
$time_played = round($minues_played / 60) . 'h:';
|
||||
$time_played .= $minues_played % 60 . 'm';
|
||||
|
||||
$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->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->player_name . ' (' . $events_played . ') (' . $time_played . '';
|
||||
$arr[$position][$val->ss_player_id] = '<span class="text-blue-600 dark:text-blue-500">' . $val->details->player_name . ' (' . $events_played . ') (' . $time_played . ')</span>';
|
||||
} else {
|
||||
$arr[$position][$val->ss_player_id] = '<span class="text-green-600 dark:text-green-500">' . $val->details->player_name . ' (' . $events_played . ') (' . $time_played . ')</span>';
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ class Sofascore
|
||||
{
|
||||
public static string $storage;
|
||||
|
||||
public static string $archive_name;
|
||||
public static string $zipfile;
|
||||
|
||||
public static string $excel_name;
|
||||
|
||||
@@ -90,30 +90,40 @@ class Sofascore
|
||||
public static function setStorage()
|
||||
{
|
||||
$task = Nuh::$options['task'];
|
||||
$debug = Nuh::$options['d'];
|
||||
|
||||
self::$storage = storage_path('sofascore_data') . '/';
|
||||
// for grapper to start with
|
||||
$sofascore_data = storage_path('sofascore_data') . '/';
|
||||
$task = SofaScoreTask::where('id', $task)->first();
|
||||
if (!$task) {
|
||||
Notice::note("No SofaScoreTask " . Nuh::$options['task'], 'r', 1);
|
||||
}
|
||||
$storage_name = Strings::clean($task->name);
|
||||
|
||||
$storage_name = Strings::clean(SofaScoreTask::where('id', $task)->value('name')) . '/';
|
||||
|
||||
switch ($task) {
|
||||
switch ($task->id) {
|
||||
case 1:
|
||||
self::$archive_name = Carbon::now()->subDays(3)->format('Y-m-d') . '.zip';
|
||||
self::$storage .= $storage_name . Carbon::now()->subDays(3)->format('Y-m-d');
|
||||
self::$storage = $sofascore_data . $storage_name . '/' . Carbon::now()->subDays(3)->format('Y-m-d');
|
||||
self::$zipfile = $sofascore_data . $storage_name . '/' . Carbon::now()->subDays(3)->format('Y-m-d') . '.zip';
|
||||
break;
|
||||
case 2:
|
||||
self::$storage = $sofascore_data . $storage_name . '/' . $task->day_from;
|
||||
self::$zipfile = $sofascore_data . $storage_name . '/' . $task->day_from . '.zip';
|
||||
break;
|
||||
case 3:
|
||||
self::$archive_name = $storage_name . '.zip';
|
||||
self::$storage .= $storage_name;
|
||||
self::$storage = $sofascore_data . $storage_name . '-' . $task->day_from . '-' . $task->day_to;
|
||||
self::$zipfile = $sofascore_data . $storage_name . '-' . $task->day_from . '-' . $task->day_to . '.zip';
|
||||
break;
|
||||
case 4:
|
||||
self::$archive_name = 'rosa-' . Carbon::now()->format('Y-m-d') . '.zip';
|
||||
self::$storage .= $storage_name . 'rosa-' . Carbon::now()->format('Y-m-d');
|
||||
self::$storage = $sofascore_data . $storage_name . '/rosa-' . Carbon::now()->format('Y-m-d');
|
||||
self::$zipfile = $sofascore_data . $storage_name . '/rosa-' . Carbon::now()->format('Y-m-d') . '.zip';
|
||||
break;
|
||||
|
||||
default:
|
||||
self::$archive_name = 'archive.zip';
|
||||
self::$storage = $sofascore_data . $storage_name;
|
||||
self::$zipfile = $sofascore_data . $storage_name . '/archive.zip';
|
||||
break;
|
||||
}
|
||||
|
||||
if ($debug)
|
||||
Notice::note("\nStore:\t" . Sofascore::$storage . "\nZip:\t" . Sofascore::$zipfile, 'c');
|
||||
}
|
||||
}
|
||||
@@ -12,11 +12,9 @@ class ZipFolder
|
||||
public static function create()
|
||||
{
|
||||
|
||||
$zipFilePath = Sofascore::$storage . Sofascore::$archive_name;
|
||||
|
||||
$zip = new ZipArchive();
|
||||
|
||||
if ($zip->open($zipFilePath, ZipArchive::CREATE | ZipArchive::OVERWRITE) === true) {
|
||||
if ($zip->open(Sofascore::$zipfile, ZipArchive::CREATE | ZipArchive::OVERWRITE) === true) {
|
||||
|
||||
if (is_dir(Sofascore::$storage)) {
|
||||
|
||||
|
||||
@@ -3,37 +3,78 @@
|
||||
namespace App\Console\Commands\Grapper\Sofascore;
|
||||
|
||||
use App\Console\Commands\Grapper\Sofascore;
|
||||
use App\Console\Commands\Grapper\Sofascore\Helper\Strings;
|
||||
use App\Console\Commands\Grapper\Sofascore\Helper\ZipFolder;
|
||||
use App\Console\Commands\Nuh;
|
||||
use Spatie\SimpleExcel\SimpleExcelWriter;
|
||||
use App\Utilities\Notice;
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
|
||||
class MakeExcel
|
||||
{
|
||||
public static $FOLDER = 'Season-25-26-Major-Leagues';
|
||||
public static $MAXCOLUMNS = 1000;
|
||||
|
||||
public static function create()
|
||||
{
|
||||
$files = ZipFolder::get_tree(Sofascore::$storage);
|
||||
ini_set("memory_limit", -1);
|
||||
|
||||
$writer = SimpleExcelWriter::create(Sofascore::$storage . '.xlsx');
|
||||
$debug = Nuh::$options['d'] ?? 0;
|
||||
|
||||
foreach ($files as $file) {
|
||||
if ($debug) {
|
||||
Notice::note("Make Excel", 'bb');
|
||||
}
|
||||
|
||||
$name = str_replace('.json', '', basename($file));
|
||||
$writer->addHeader(['#TEAM# ' . $name]);
|
||||
if ($debug) {
|
||||
Notice::note("Folder to Import: " . self::$FOLDER . "\nMaximum in Excel: " . self::$MAXCOLUMNS, 'b');
|
||||
}
|
||||
|
||||
$data = file_get_contents($file);
|
||||
$files = self::load_files();
|
||||
|
||||
$arr = json_decode($data, true);
|
||||
foreach ($files as $key => $value) {
|
||||
|
||||
if (isset($arr['players']) && is_array($arr['players'])) {
|
||||
foreach ($arr['players'] as $value) {
|
||||
if ($value) {
|
||||
$writer->addRow([$name => json_encode($value)]);
|
||||
}
|
||||
$from = $key * self::$MAXCOLUMNS + 1;
|
||||
$key++;
|
||||
$to = $key * self::$MAXCOLUMNS;
|
||||
$filename = self::$FOLDER . '-' . $from . '-' . $to . '.xlsx';
|
||||
|
||||
$spreadsheet = new Spreadsheet;
|
||||
$spreadsheet->getProperties()->setTitle($filename);
|
||||
$activeWorksheet = $spreadsheet->getActiveSheet();
|
||||
|
||||
$column = 1;
|
||||
foreach ($value as $file) {
|
||||
$data = file_get_contents($file);
|
||||
$data = json_decode($data, true);
|
||||
$json_string = json_encode($data, JSON_PRETTY_PRINT);
|
||||
|
||||
$arr = explode(PHP_EOL, $json_string);
|
||||
$row = 0;
|
||||
foreach ($arr as $val) {
|
||||
$row++;
|
||||
$activeWorksheet->setCellValue([$column, $row], trim($val));
|
||||
}
|
||||
$column++;
|
||||
}
|
||||
|
||||
$spreadsheet->setActiveSheetIndex(0);
|
||||
$writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
|
||||
$writer->save(Sofascore::$storage . '/' . $filename);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static function load_files()
|
||||
{
|
||||
$files = ZipFolder::get_tree(Sofascore::$storage . '/' . self::$FOLDER);
|
||||
|
||||
$filtered = [];
|
||||
foreach ($files as $file) {
|
||||
$path_parts = pathinfo($file);
|
||||
if (isset($path_parts['extension']) && $path_parts['extension'] == 'json') {
|
||||
$filtered[] = $file;
|
||||
}
|
||||
}
|
||||
|
||||
$writer->close();
|
||||
return array_chunk($filtered, self::$MAXCOLUMNS);
|
||||
}
|
||||
}
|
||||
-5
@@ -49,9 +49,4 @@ class CompetitionGroupResource extends Resource
|
||||
{
|
||||
return parent::getEloquentQuery()->count();
|
||||
}
|
||||
|
||||
public static function getNavigationBadgeColor(): ?string
|
||||
{
|
||||
return 'warning';
|
||||
}
|
||||
}
|
||||
@@ -142,11 +142,6 @@ class CountryResource extends Resource
|
||||
return parent::getEloquentQuery()->where('disabled', false)->count();
|
||||
}
|
||||
|
||||
public static function getNavigationBadgeColor(): ?string
|
||||
{
|
||||
return 'warning';
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()->where('disabled', false);
|
||||
|
||||
@@ -45,9 +45,4 @@ class ElementResource extends Resource
|
||||
{
|
||||
return parent::getEloquentQuery()->count();
|
||||
}
|
||||
|
||||
public static function getNavigationBadgeColor(): ?string
|
||||
{
|
||||
return 'warning';
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,8 @@ class SofaScoreRosaResource extends Resource
|
||||
|
||||
protected static ?string $cluster = StaticDataCluster::class;
|
||||
|
||||
protected static ?int $navigationSort = 3;
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
protected static ?string $navigationLabel = 'Rosters';
|
||||
|
||||
@@ -24,7 +24,7 @@ class SofaScoreTaskResource extends Resource
|
||||
|
||||
protected static ?string $modelLabel = 'Tasks';
|
||||
|
||||
protected static ?int $navigationSort = 1;
|
||||
protected static ?int $navigationSort = 2;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'SofaScore';
|
||||
|
||||
|
||||
+3
-2
@@ -22,9 +22,10 @@ class SofaScoreTasksTable
|
||||
->icon(fn($record) => $record->sport->icon),
|
||||
TextColumn::make('sport.name'),
|
||||
TextColumn::make('mode')
|
||||
->label('Grapping dates')
|
||||
->label('Grapping Task')
|
||||
->formatStateUsing(fn(string $state, $record): string => match ($state) {
|
||||
'daily' => 'Daily',
|
||||
'daily' => 'Daily run',
|
||||
'excel' => 'Import to Excel',
|
||||
'date' => $record->day_from,
|
||||
'range' => $record->day_from . ' <=> ' . $record->day_to,
|
||||
}),
|
||||
|
||||
+2
-2
@@ -20,9 +20,9 @@ class StatisticFixturesResource extends Resource
|
||||
|
||||
protected static ?string $modelLabel = 'Fixtures';
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Statistiko';
|
||||
protected static string|UnitEnum|null $navigationGroup = 'SofaScore';
|
||||
|
||||
protected static ?int $navigationSort = 2;
|
||||
protected static ?int $navigationSort = 5;
|
||||
|
||||
protected static ?string $cluster = StaticDataCluster::class;
|
||||
|
||||
|
||||
+40
-15
@@ -3,15 +3,19 @@
|
||||
namespace App\Filament\Clusters\StaticData\Resources\StatisticFixtures\Tables;
|
||||
|
||||
use App\Actions\LoadStatisticFixturesLeaguesOptions;
|
||||
use App\Models\Sport;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Enums\FiltersLayout;
|
||||
use Filament\Tables\Filters\SelectFilter;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class StatisticFixturesTable
|
||||
{
|
||||
@@ -30,30 +34,51 @@ class StatisticFixturesTable
|
||||
TextColumn::make('league.name')
|
||||
->label('League')
|
||||
->searchable()
|
||||
->wrap()
|
||||
->tooltip(fn($record) => $record->league_id)
|
||||
->hidden(fn() => auth()->user()->sport_id == 5)
|
||||
->description(fn($record) => ucwords($record->league?->country->name)),
|
||||
->description(
|
||||
fn($record) => $record->league->sofascore_category->name
|
||||
),
|
||||
TextColumn::make('starttime')->dateTime('Y-m-d H:i'),
|
||||
TextColumn::make('home.name')
|
||||
TextColumn::make('home.ss_team_name')
|
||||
->tooltip(fn($record) => $record->home_id)
|
||||
->color('primary')
|
||||
->searchable(),
|
||||
TextColumn::make('away.name')
|
||||
TextColumn::make('away.ss_team_name')
|
||||
->tooltip(fn($record) => $record->away_id)
|
||||
->color('success')
|
||||
->searchable(),
|
||||
// TextColumn::make('exp_home')->alignCenter()->numeric(),
|
||||
// TextColumn::make('exp_away')->alignCenter()->numeric(),
|
||||
TextColumn::make('updated_at')->alignCenter()->date(),
|
||||
])
|
||||
->filters([
|
||||
SelectFilter::make('league_id')
|
||||
->options(fn() => LoadStatisticFixturesLeaguesOptions::load(1))
|
||||
->preload()
|
||||
->searchable()
|
||||
->columnSpan(2)
|
||||
->label('League'),
|
||||
Filter::make('fixture_filters')
|
||||
->columns(3)
|
||||
->columnSpan(3)
|
||||
->schema([
|
||||
Select::make('sport_id')
|
||||
->default(1)
|
||||
->options(fn() => Sport::query()->where('is_active', 1)->pluck('name', 'id'))
|
||||
->selectablePlaceholder(false)
|
||||
->label('Sport')
|
||||
->live(),
|
||||
Select::make('league_id')
|
||||
->options(fn(Get $get) => LoadStatisticFixturesLeaguesOptions::load($get('sport_id')))
|
||||
->preload()
|
||||
->searchable()
|
||||
->columnSpan(2)
|
||||
->label('League'),
|
||||
])->query(function (Builder $query, array $data): Builder {
|
||||
return $query->when(
|
||||
$data['league_id'],
|
||||
function (Builder $query, $league_id) {
|
||||
$query->where('league_id', $league_id)->orderBy('league_id');
|
||||
}
|
||||
)->when(
|
||||
$data['sport_id'],
|
||||
function (Builder $query, $away_id) {
|
||||
$query->where('sport_id', (int) $away_id);
|
||||
}
|
||||
);
|
||||
}),
|
||||
|
||||
], layout: FiltersLayout::AboveContent)
|
||||
->deferFilters(false)
|
||||
->recordActions([
|
||||
|
||||
+2
-2
@@ -20,11 +20,11 @@ class StatistikoDetailResource extends Resource
|
||||
|
||||
protected static ?string $modelLabel = 'Details';
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Statistiko';
|
||||
protected static string|UnitEnum|null $navigationGroup = 'SofaScore';
|
||||
|
||||
protected static ?string $cluster = StaticDataCluster::class;
|
||||
|
||||
protected static ?int $navigationSort = 4;
|
||||
protected static ?int $navigationSort = 9;
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'player_name';
|
||||
|
||||
|
||||
+2
-2
@@ -20,9 +20,9 @@ class StatistikoEventsResource extends Resource
|
||||
|
||||
protected static ?string $modelLabel = 'Events';
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Statistiko';
|
||||
protected static string|UnitEnum|null $navigationGroup = 'SofaScore';
|
||||
|
||||
protected static ?int $navigationSort = 3;
|
||||
protected static ?int $navigationSort = 6;
|
||||
|
||||
protected static ?string $cluster = StaticDataCluster::class;
|
||||
|
||||
|
||||
+5
-16
@@ -35,23 +35,12 @@ class StatistikoEventsTable
|
||||
TextColumn::make('match_id')
|
||||
->sortable(),
|
||||
TextColumn::make('league.name')
|
||||
->searchable()
|
||||
->copyable()
|
||||
->copyMessage('Liga name copied')
|
||||
->description(fn($record) => ucwords($record->league?->country->name))
|
||||
->copyMessageDuration(1500),
|
||||
TextColumn::make('home.name')
|
||||
->searchable()
|
||||
->copyable()
|
||||
->copyMessage('Home team name copied')
|
||||
->copyMessageDuration(1500),
|
||||
TextColumn::make('away.name')
|
||||
->searchable()
|
||||
->copyable()
|
||||
->copyMessage('Away team name copied')
|
||||
->copyMessageDuration(1500),
|
||||
->searchable(),
|
||||
TextColumn::make('home.ss_team_name')->color('info')
|
||||
->searchable(),
|
||||
TextColumn::make('away.ss_team_name')->color('success')
|
||||
->searchable(),
|
||||
TextColumn::make('starttime')->dateTime('Y-m-d H:i'),
|
||||
|
||||
])
|
||||
->filters([
|
||||
Filter::make('event_filters')
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ class StatistikaImportResource extends Resource
|
||||
|
||||
protected static ?string $modelLabel = 'File Uploads';
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Statistiko';
|
||||
protected static string|UnitEnum|null $navigationGroup = 'SofaScore';
|
||||
|
||||
protected static ?int $navigationSort = 1;
|
||||
|
||||
|
||||
+2
-2
@@ -20,11 +20,11 @@ class StatistikoPlayerResource extends Resource
|
||||
|
||||
protected static ?string $modelLabel = 'Player';
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Statistiko';
|
||||
protected static string|UnitEnum|null $navigationGroup = 'SofaScore';
|
||||
|
||||
protected static ?string $cluster = StaticDataCluster::class;
|
||||
|
||||
protected static ?int $navigationSort = 5;
|
||||
protected static ?int $navigationSort = 8;
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'player.name';
|
||||
|
||||
|
||||
@@ -3,9 +3,14 @@
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use MongoDB\Laravel\Eloquent\HybridRelations;
|
||||
|
||||
class SofaScoreTournament extends Model
|
||||
{
|
||||
use HybridRelations;
|
||||
|
||||
protected $connection = 'mariadb';
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'sport_id',
|
||||
|
||||
@@ -30,7 +30,7 @@ class StatisticFixtures extends Model
|
||||
|
||||
public function league()
|
||||
{
|
||||
return $this->belongsTo(CompetitionGroup::class);
|
||||
return $this->belongsTo(SofaScoreTournament::class, 'league_id', 'tournament_id');
|
||||
}
|
||||
|
||||
public function home()
|
||||
|
||||
@@ -53,18 +53,18 @@ class StatistikoEvent extends Model
|
||||
return $this->belongsTo(Sport::class, 'sport_id', 'id');
|
||||
}
|
||||
|
||||
public function league(): BelongsTo
|
||||
public function league()
|
||||
{
|
||||
return $this->belongsTo(CompetitionGroup::class, 'league_id', 'id');
|
||||
return $this->belongsTo(SofaScoreTournament::class, 'league_id', 'tournament_id');
|
||||
}
|
||||
|
||||
public function home(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Element::class, 'home_id', 'id');
|
||||
return $this->belongsTo(SofaScoreRosa::class, 'home_id', 'ss_team_id');
|
||||
}
|
||||
|
||||
public function away(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Element::class, 'away_id', 'id');
|
||||
return $this->belongsTo(SofaScoreRosa::class, 'away_id', 'ss_team_id');
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@ use Filament\Http\Middleware\Authenticate;
|
||||
use Filament\Http\Middleware\AuthenticateSession;
|
||||
use Filament\Http\Middleware\DisableBladeIconComponents;
|
||||
use Filament\Http\Middleware\DispatchServingFilamentEvent;
|
||||
use Filament\Navigation\NavigationGroup;
|
||||
use Filament\Panel;
|
||||
use Filament\PanelProvider;
|
||||
use Filament\Support\Enums\Width;
|
||||
@@ -64,7 +65,6 @@ class AdminPanelProvider extends PanelProvider
|
||||
->emailChangeVerification()
|
||||
->databaseNotifications()
|
||||
->databaseNotificationsPolling('10s') // default is 30
|
||||
->sidebarCollapsibleOnDesktop()
|
||||
->profile(isSimple: false)
|
||||
->default()
|
||||
->globalSearch(false)
|
||||
@@ -85,11 +85,10 @@ class AdminPanelProvider extends PanelProvider
|
||||
->viteTheme('resources/css/filament/admin/theme.css')
|
||||
->discoverResources(in: app_path('Filament/Resources'), for: 'App\Filament\Resources')
|
||||
->discoverPages(in: app_path('Filament/Pages'), for: 'App\Filament\Pages')
|
||||
// ->discoverWidgets(in: app_path('Filament/Widgets'), for: 'App\Filament\Widgets')
|
||||
->discoverWidgets(in: app_path('Filament/Widgets'), for: 'App\Filament\Widgets')
|
||||
->discoverClusters(in: app_path('Filament/Clusters'), for: 'App\\Filament\\Clusters')
|
||||
->maxContentWidth(Width::ScreenTwoExtraLarge)
|
||||
->breadcrumbs(false)
|
||||
->topNavigation()
|
||||
->sidebarCollapsibleOnDesktop(false)
|
||||
->userMenuItems([
|
||||
'profile' => Action::make('profile')
|
||||
|
||||
Reference in new issue
Block a user