From 5d8d81b100964f38ae14cf276e3a923574f2efc1 Mon Sep 17 00:00:00 2001 From: Wes Copeland Date: Fri, 24 Jan 2025 21:31:05 -0500 Subject: [PATCH 1/8] feat(manage): add has_box_art filter to GameResource --- app/Filament/Resources/GameResource.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/app/Filament/Resources/GameResource.php b/app/Filament/Resources/GameResource.php index f643dd68eb..f53474ce5d 100644 --- a/app/Filament/Resources/GameResource.php +++ b/app/Filament/Resources/GameResource.php @@ -496,6 +496,25 @@ public static function table(Table $table): Table false: fn (Builder $query): Builder => $query->where('achievements_published', '<', 6), blank: fn (Builder $query): Builder => $query, ), + + Tables\Filters\TernaryFilter::make('has_box_art') + ->label('Has box art') + ->placeholder('Any') + ->trueLabel('Yes') + ->falseLabel('No') + ->queries( + true: fn (Builder $query): Builder => $query + ->whereNotNull('ImageBoxArt') + ->whereNotIn('ConsoleID', System::getNonGameSystems()) + ->where('ImageBoxArt', '!=', '/Images/000002.png'), + false: fn (Builder $query): Builder => $query + ->whereNotIn('ConsoleID', System::getNonGameSystems()) + ->where(fn (Builder $query): Builder => $query + ->whereNull('ImageBoxArt') + ->orWhere('ImageBoxArt', '/Images/000002.png') + ), + blank: fn (Builder $query): Builder => $query, + ), ]) ->actions([ Tables\Actions\ActionGroup::make([ From 80a3bf51b674a831294d07a409e8b1c1746bcd1b Mon Sep 17 00:00:00 2001 From: Wes Copeland Date: Sat, 25 Jan 2025 15:43:21 -0500 Subject: [PATCH 2/8] fix: address feedback --- app/Filament/Resources/GameResource.php | 75 ++++++++++++++++++++++++- 1 file changed, 74 insertions(+), 1 deletion(-) diff --git a/app/Filament/Resources/GameResource.php b/app/Filament/Resources/GameResource.php index f53474ce5d..6ac6abf501 100644 --- a/app/Filament/Resources/GameResource.php +++ b/app/Filament/Resources/GameResource.php @@ -484,7 +484,23 @@ public static function table(Table $table): Table ]) ->filters([ Tables\Filters\SelectFilter::make('system') - ->relationship('system', 'Name'), + ->options(function () { + $options = ['active' => 'All Active Systems']; + $systemOptions = System::orderBy('Name') + ->pluck('Name', 'ID') + ->toArray(); + + return $options + $systemOptions; + }) + ->query(function (Builder $query, $data) { + $value = $data['value'] ?? null; + + if ($value === 'active') { + $query->whereIn('ConsoleID', System::active()->pluck('ID')); + } elseif ($value) { + $query->where('ConsoleID', $value); + } + }), Tables\Filters\TernaryFilter::make('achievements_published') ->label('Has core set') @@ -497,6 +513,63 @@ public static function table(Table $table): Table blank: fn (Builder $query): Builder => $query, ), + Tables\Filters\TernaryFilter::make('has_badge') + ->label('Has badge') + ->placeholder('Any') + ->trueLabel('Yes') + ->falseLabel('No') + ->queries( + true: fn (Builder $query): Builder => $query + ->whereNotNull('ImageIcon') + ->whereNotIn('ConsoleID', System::getNonGameSystems()) + ->where('ImageIcon', '!=', '/Images/000001.png'), + false: fn (Builder $query): Builder => $query + ->whereNotIn('ConsoleID', System::getNonGameSystems()) + ->where(fn (Builder $query): Builder => $query + ->whereNull('ImageIcon') + ->orWhere('ImageIcon', '/Images/000001.png') + ), + blank: fn (Builder $query): Builder => $query, + ), + + Tables\Filters\TernaryFilter::make('has_title_image') + ->label('Has title image') + ->placeholder('Any') + ->trueLabel('Yes') + ->falseLabel('No') + ->queries( + true: fn (Builder $query): Builder => $query + ->whereNotNull('ImageTitle') + ->whereNotIn('ConsoleID', System::getNonGameSystems()) + ->where('ImageTitle', '!=', '/Images/000002.png'), + false: fn (Builder $query): Builder => $query + ->whereNotIn('ConsoleID', System::getNonGameSystems()) + ->where(fn (Builder $query): Builder => $query + ->whereNull('ImageTitle') + ->orWhere('ImageTitle', '/Images/000002.png') + ), + blank: fn (Builder $query): Builder => $query, + ), + + Tables\Filters\TernaryFilter::make('has_in_game_image') + ->label('Has in game Image') + ->placeholder('Any') + ->trueLabel('Yes') + ->falseLabel('No') + ->queries( + true: fn (Builder $query): Builder => $query + ->whereNotNull('ImageIngame') + ->whereNotIn('ConsoleID', System::getNonGameSystems()) + ->where('ImageIngame', '!=', '/Images/000002.png'), + false: fn (Builder $query): Builder => $query + ->whereNotIn('ConsoleID', System::getNonGameSystems()) + ->where(fn (Builder $query): Builder => $query + ->whereNull('ImageIngame') + ->orWhere('ImageIngame', '/Images/000002.png') + ), + blank: fn (Builder $query): Builder => $query, + ), + Tables\Filters\TernaryFilter::make('has_box_art') ->label('Has box art') ->placeholder('Any') From 42b2e230cba8339919e8ffceeac9dcaa1dcbe546 Mon Sep 17 00:00:00 2001 From: Wes Copeland Date: Sun, 26 Jan 2025 10:34:14 -0500 Subject: [PATCH 3/8] fix: address feedback --- app/Filament/Resources/GameResource.php | 112 +++++++++--------------- 1 file changed, 39 insertions(+), 73 deletions(-) diff --git a/app/Filament/Resources/GameResource.php b/app/Filament/Resources/GameResource.php index 6ac6abf501..c4d6b7975a 100644 --- a/app/Filament/Resources/GameResource.php +++ b/app/Filament/Resources/GameResource.php @@ -513,80 +513,46 @@ public static function table(Table $table): Table blank: fn (Builder $query): Builder => $query, ), - Tables\Filters\TernaryFilter::make('has_badge') - ->label('Has badge') - ->placeholder('Any') - ->trueLabel('Yes') - ->falseLabel('No') - ->queries( - true: fn (Builder $query): Builder => $query - ->whereNotNull('ImageIcon') - ->whereNotIn('ConsoleID', System::getNonGameSystems()) - ->where('ImageIcon', '!=', '/Images/000001.png'), - false: fn (Builder $query): Builder => $query - ->whereNotIn('ConsoleID', System::getNonGameSystems()) - ->where(fn (Builder $query): Builder => $query - ->whereNull('ImageIcon') - ->orWhere('ImageIcon', '/Images/000001.png') - ), - blank: fn (Builder $query): Builder => $query, - ), - - Tables\Filters\TernaryFilter::make('has_title_image') - ->label('Has title image') - ->placeholder('Any') - ->trueLabel('Yes') - ->falseLabel('No') - ->queries( - true: fn (Builder $query): Builder => $query - ->whereNotNull('ImageTitle') - ->whereNotIn('ConsoleID', System::getNonGameSystems()) - ->where('ImageTitle', '!=', '/Images/000002.png'), - false: fn (Builder $query): Builder => $query - ->whereNotIn('ConsoleID', System::getNonGameSystems()) - ->where(fn (Builder $query): Builder => $query - ->whereNull('ImageTitle') - ->orWhere('ImageTitle', '/Images/000002.png') - ), - blank: fn (Builder $query): Builder => $query, - ), - - Tables\Filters\TernaryFilter::make('has_in_game_image') - ->label('Has in game Image') - ->placeholder('Any') - ->trueLabel('Yes') - ->falseLabel('No') - ->queries( - true: fn (Builder $query): Builder => $query - ->whereNotNull('ImageIngame') - ->whereNotIn('ConsoleID', System::getNonGameSystems()) - ->where('ImageIngame', '!=', '/Images/000002.png'), - false: fn (Builder $query): Builder => $query - ->whereNotIn('ConsoleID', System::getNonGameSystems()) - ->where(fn (Builder $query): Builder => $query - ->whereNull('ImageIngame') - ->orWhere('ImageIngame', '/Images/000002.png') - ), - blank: fn (Builder $query): Builder => $query, - ), + Tables\Filters\SelectFilter::make('missing_assets') + ->label('Missing assets') + ->multiple() + ->options([ + 'badge' => 'Badge icon', + 'title' => 'Title image', + 'ingame' => 'In-game image', + 'boxart' => 'Box art', + ]) + ->query(function (Builder $query, array $data): Builder { + if (empty($data['values'])) { + return $query; + } - Tables\Filters\TernaryFilter::make('has_box_art') - ->label('Has box art') - ->placeholder('Any') - ->trueLabel('Yes') - ->falseLabel('No') - ->queries( - true: fn (Builder $query): Builder => $query - ->whereNotNull('ImageBoxArt') - ->whereNotIn('ConsoleID', System::getNonGameSystems()) - ->where('ImageBoxArt', '!=', '/Images/000002.png'), - false: fn (Builder $query): Builder => $query - ->whereNotIn('ConsoleID', System::getNonGameSystems()) - ->where(fn (Builder $query): Builder => $query - ->whereNull('ImageBoxArt') - ->orWhere('ImageBoxArt', '/Images/000002.png') - ), - blank: fn (Builder $query): Builder => $query, + return $query->whereNotIn('ConsoleID', System::getNonGameSystems()) + ->where(function (Builder $query) use ($data) { + foreach ($data['values'] as $type) { + $query->where(function (Builder $query) use ($type) { + switch ($type) { + case 'badge': + $query->whereNull('ImageIcon') + ->orWhere('ImageIcon', '/Images/000001.png'); + break; + case 'title': + $query->whereNull('ImageTitle') + ->orWhere('ImageTitle', '/Images/000002.png'); + break; + case 'ingame': + $query->whereNull('ImageIngame') + ->orWhere('ImageIngame', '/Images/000002.png'); + break; + case 'boxart': + $query->whereNull('ImageBoxArt') + ->orWhere('ImageBoxArt', '/Images/000002.png'); + break; + } + }); + } + }); + } ), ]) ->actions([ From 9931c0d2633fa6d2eccb10852f3a9009fb880744 Mon Sep 17 00:00:00 2001 From: Wes Copeland Date: Sun, 26 Jan 2025 10:34:36 -0500 Subject: [PATCH 4/8] fix: update label --- app/Filament/Resources/GameResource.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Filament/Resources/GameResource.php b/app/Filament/Resources/GameResource.php index c4d6b7975a..e33b7f91ad 100644 --- a/app/Filament/Resources/GameResource.php +++ b/app/Filament/Resources/GameResource.php @@ -513,8 +513,8 @@ public static function table(Table $table): Table blank: fn (Builder $query): Builder => $query, ), - Tables\Filters\SelectFilter::make('missing_assets') - ->label('Missing assets') + Tables\Filters\SelectFilter::make('missing_media') + ->label('Missing media') ->multiple() ->options([ 'badge' => 'Badge icon', From 8cfacf2722e3e5b7ba0ae47e669023b18e0afa5a Mon Sep 17 00:00:00 2001 From: Wes Copeland Date: Sun, 26 Jan 2025 10:42:37 -0500 Subject: [PATCH 5/8] ci: force install?? --- .github/workflows/ci.yml | 49 ++-------------------------------------- 1 file changed, 2 insertions(+), 47 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f63f94f148..3a15904e0e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,45 +45,6 @@ jobs: if: steps.composer-cache.outputs.cache-hit != 'true' run: composer install --prefer-dist - node-setup: - runs-on: ubuntu-22.04 - name: Node.js Setup - outputs: - cache-key: ${{ steps.cache-key.outputs.value }} - steps: - - name: Checkout code - uses: actions/checkout@v4 - with: - fetch-depth: 1 - - - name: Install pnpm - uses: pnpm/action-setup@v4 - with: - version: 9 - - - name: Use Node 20 - uses: actions/setup-node@v4 - with: - node-version: '20' - cache: 'pnpm' - - - name: Generate cache key - id: cache-key - run: echo "value=${{ runner.os }}-node-${{ hashFiles('**/pnpm-lock.yaml') }}" >> $GITHUB_OUTPUT - - - name: Install - if: steps.node-cache.outputs.cache-hit != 'true' - run: pnpm install --frozen-lockfile --prefer-offline - - - name: Cache node_modules - id: node-cache - uses: actions/cache@v4 - with: - path: | - node_modules - .pnpm-store - key: ${{ steps.cache-key.outputs.value }} - php-checks: needs: php-setup runs-on: ubuntu-22.04 @@ -123,7 +84,6 @@ jobs: run: ${{ matrix.command }} node-checks: - needs: node-setup runs-on: ubuntu-22.04 name: Node.js Checks strategy: @@ -154,13 +114,8 @@ jobs: with: node-version: '20' cache: 'pnpm' - - name: Restore node_modules - uses: actions/cache@v4 - with: - path: | - node_modules - .pnpm-store - key: ${{ needs.node-setup.outputs.cache-key }} + - name: Install + run: pnpm i - name: Run ${{ matrix.check }} run: ${{ matrix.command }} env: ${{ matrix.env || fromJSON('{}') }} From ead8d5495c07e1c6a81a67faec80edd7125112c7 Mon Sep 17 00:00:00 2001 From: Wes Copeland Date: Wed, 29 Jan 2025 19:32:40 -0500 Subject: [PATCH 6/8] fix: address feedback --- app/Filament/Resources/GameResource.php | 105 ++++++++++++++++-------- 1 file changed, 71 insertions(+), 34 deletions(-) diff --git a/app/Filament/Resources/GameResource.php b/app/Filament/Resources/GameResource.php index e33b7f91ad..a196ba5700 100644 --- a/app/Filament/Resources/GameResource.php +++ b/app/Filament/Resources/GameResource.php @@ -513,47 +513,84 @@ public static function table(Table $table): Table blank: fn (Builder $query): Builder => $query, ), - Tables\Filters\SelectFilter::make('missing_media') - ->label('Missing media') - ->multiple() + Tables\Filters\SelectFilter::make('media') + ->label('Media') + ->placeholder('Select a value') ->options([ - 'badge' => 'Badge icon', - 'title' => 'Title image', - 'ingame' => 'In-game image', - 'boxart' => 'Box art', + 'none' => 'Has all media', + 'all' => 'Missing all media', + 'any' => 'Missing any media', + 'badge' => 'Missing badge icon', + 'boxart' => 'Missing box art', + 'title' => 'Missing title image', + 'ingame' => 'Missing in-game image', ]) ->query(function (Builder $query, array $data): Builder { - if (empty($data['values'])) { + if (empty($data['value'])) { return $query; } - return $query->whereNotIn('ConsoleID', System::getNonGameSystems()) - ->where(function (Builder $query) use ($data) { - foreach ($data['values'] as $type) { - $query->where(function (Builder $query) use ($type) { - switch ($type) { - case 'badge': - $query->whereNull('ImageIcon') - ->orWhere('ImageIcon', '/Images/000001.png'); - break; - case 'title': - $query->whereNull('ImageTitle') - ->orWhere('ImageTitle', '/Images/000002.png'); - break; - case 'ingame': - $query->whereNull('ImageIngame') - ->orWhere('ImageIngame', '/Images/000002.png'); - break; - case 'boxart': - $query->whereNull('ImageBoxArt') - ->orWhere('ImageBoxArt', '/Images/000002.png'); - break; - } - }); - } - }); + $query = $query->whereNotIn('ConsoleID', System::getNonGameSystems()); + + switch ($data['value']) { + case 'none': + return $query->whereNotNull('ImageIcon') + ->where('ImageIcon', '!=', '/Images/000001.png') + ->whereNotNull('ImageTitle') + ->where('ImageTitle', '!=', '/Images/000002.png') + ->whereNotNull('ImageIngame') + ->where('ImageIngame', '!=', '/Images/000002.png') + ->whereNotNull('ImageBoxArt') + ->where('ImageBoxArt', '!=', '/Images/000002.png'); + case 'all': + return $query->where(function ($query) { + $query->whereNull('ImageIcon') + ->orWhere('ImageIcon', '/Images/000001.png'); + })->where(function ($query) { + $query->whereNull('ImageTitle') + ->orWhere('ImageTitle', '/Images/000002.png'); + })->where(function ($query) { + $query->whereNull('ImageIngame') + ->orWhere('ImageIngame', '/Images/000002.png'); + })->where(function ($query) { + $query->whereNull('ImageBoxArt') + ->orWhere('ImageBoxArt', '/Images/000002.png'); + }); + case 'any': + return $query->where(function ($query) { + $query->whereNull('ImageIcon') + ->orWhere('ImageIcon', '/Images/000001.png') + ->orWhereNull('ImageTitle') + ->orWhere('ImageTitle', '/Images/000002.png') + ->orWhereNull('ImageIngame') + ->orWhere('ImageIngame', '/Images/000002.png') + ->orWhereNull('ImageBoxArt') + ->orWhere('ImageBoxArt', '/Images/000002.png'); + }); + case 'badge': + return $query->where(function ($query) { + $query->whereNull('ImageIcon') + ->orWhere('ImageIcon', '/Images/000001.png'); + }); + case 'boxart': + return $query->where(function ($query) { + $query->whereNull('ImageBoxArt') + ->orWhere('ImageBoxArt', '/Images/000002.png'); + }); + case 'title': + return $query->where(function ($query) { + $query->whereNull('ImageTitle') + ->orWhere('ImageTitle', '/Images/000002.png'); + }); + case 'ingame': + return $query->where(function ($query) { + $query->whereNull('ImageIngame') + ->orWhere('ImageIngame', '/Images/000002.png'); + }); + default: + return $query; } - ), + }), ]) ->actions([ Tables\Actions\ActionGroup::make([ From 41d8e81cc738da44b237af8fd293bc59494804f9 Mon Sep 17 00:00:00 2001 From: Wes Copeland Date: Fri, 31 Jan 2025 17:08:41 -0500 Subject: [PATCH 7/8] chore: revert ci change --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3bff77797f..fd3e270bf4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -134,6 +134,7 @@ jobs: run: ${{ matrix.command }} node-checks: + needs: node-setup runs-on: ubuntu-22.04 name: Node.js Checks strategy: From cc82868e3d5c5cec82679a807c0fc505b4fa7878 Mon Sep 17 00:00:00 2001 From: Wes Copeland Date: Fri, 31 Jan 2025 17:24:32 -0500 Subject: [PATCH 8/8] ci: still allow jobs to be marked as required while conditional --- .github/workflows/ci.yml | 42 ++++++++++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fd3e270bf4..1c4a36dec7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,6 +9,7 @@ concurrency: jobs: changes: runs-on: ubuntu-22.04 + name: Check for changes outputs: php: ${{ steps.filter.outputs.php }} node: ${{ steps.filter.outputs.node }} @@ -36,18 +37,19 @@ jobs: php-setup: needs: changes - if: needs.changes.outputs.php == 'true' runs-on: ubuntu-22.04 name: PHP Setup outputs: cache-key: ${{ steps.cache-key.outputs.value }} steps: - name: Checkout code + if: ${{ needs.changes.outputs.php == 'true' }} uses: actions/checkout@v4 with: fetch-depth: 1 - name: Setup PHP + if: ${{ needs.changes.outputs.php == 'true' }} uses: shivammathur/setup-php@v2 with: php-version: 8.2 @@ -56,10 +58,12 @@ jobs: coverage: none - name: Generate a cache key + if: ${{ needs.changes.outputs.php == 'true' }} id: cache-key run: echo "value=${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}" >> $GITHUB_OUTPUT - name: Cache composer packages + if: ${{ needs.changes.outputs.php == 'true' }} id: composer-cache uses: actions/cache@v4 with: @@ -71,32 +75,34 @@ jobs: ${{ runner.os }}-php- - name: Install - if: steps.composer-cache.outputs.cache-hit != 'true' + if: ${{ needs.changes.outputs.php == 'true' && steps.composer-cache.outputs.cache-hit != 'true' }} run: composer install --prefer-dist node-setup: needs: changes - if: needs.changes.outputs.node == 'true' runs-on: ubuntu-22.04 name: Node.js Setup steps: - name: Checkout code + if: ${{ needs.changes.outputs.node == 'true' }} uses: actions/checkout@v4 with: fetch-depth: 1 - name: Install pnpm + if: ${{ needs.changes.outputs.node == 'true' }} uses: pnpm/action-setup@v4 with: version: 9 - name: Use Node 20 + if: ${{ needs.changes.outputs.node == 'true' }} uses: actions/setup-node@v4 with: node-version: '20' php-checks: - needs: php-setup + needs: [changes, php-setup] runs-on: ubuntu-22.04 name: PHP Checks strategy: @@ -110,18 +116,27 @@ jobs: - check: test command: composer paratest -- --processes=$(nproc) steps: + - name: Check PHP changes + if: ${{ needs.changes.outputs.php != 'true' }} + run: echo "No PHP changes; skipping checks" && exit 0 + - name: Checkout code + if: ${{ needs.changes.outputs.php == 'true' }} uses: actions/checkout@v4 with: fetch-depth: 1 + - name: Setup PHP + if: ${{ needs.changes.outputs.php == 'true' }} uses: shivammathur/setup-php@v2 with: php-version: 8.2 extensions: mbstring, :psr coverage: none ini-values: memory_limit=1G + - name: Load composer packages + if: ${{ needs.changes.outputs.php == 'true' }} uses: actions/cache@v4 with: path: | @@ -130,11 +145,13 @@ jobs: key: ${{ needs.php-setup.outputs.cache-key }} restore-keys: | ${{ runner.os }}-php- + - name: Run ${{ matrix.check }} + if: ${{ needs.changes.outputs.php == 'true' }} run: ${{ matrix.command }} node-checks: - needs: node-setup + needs: [changes, node-setup] runs-on: ubuntu-22.04 name: Node.js Checks strategy: @@ -152,20 +169,33 @@ jobs: APP_URL: https://raweb.test LARAVEL_BYPASS_ENV_CHECK: 1 steps: + - name: Check Node changes + if: ${{ needs.changes.outputs.node != 'true' }} + run: echo "No Node changes; skipping checks" && exit 0 + - name: Checkout code + if: ${{ needs.changes.outputs.node == 'true' }} uses: actions/checkout@v4 with: fetch-depth: 1 + - name: Install pnpm + if: ${{ needs.changes.outputs.node == 'true' }} uses: pnpm/action-setup@v4 with: version: 9 + - name: Use Node 20 + if: ${{ needs.changes.outputs.node == 'true' }} uses: actions/setup-node@v4 with: node-version: '20' + - name: Install dependencies + if: ${{ needs.changes.outputs.node == 'true' }} run: pnpm install --frozen-lockfile --prefer-offline + - name: Run ${{ matrix.check }} + if: ${{ needs.changes.outputs.node == 'true' }} run: ${{ matrix.command }} - env: ${{ matrix.env || fromJSON('{}') }} + env: ${{ matrix.env || fromJSON('{}') }} \ No newline at end of file