Skip to content

Commit

Permalink
feat(manage): add has_box_art filter to GameResource (#3125)
Browse files Browse the repository at this point in the history
  • Loading branch information
wescopeland authored Jan 31, 2025
1 parent f035d6e commit 4367e24
Show file tree
Hide file tree
Showing 2 changed files with 132 additions and 7 deletions.
42 changes: 36 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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: |
Expand All @@ -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:
Expand All @@ -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('{}') }}
97 changes: 96 additions & 1 deletion app/Filament/Resources/GameResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,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')
Expand All @@ -498,6 +514,85 @@ public static function table(Table $table): Table
blank: fn (Builder $query): Builder => $query,
),

Tables\Filters\SelectFilter::make('media')
->label('Media')
->placeholder('Select a value')
->options([
'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['value'])) {
return $query;
}

$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;
}
}),

Tables\Filters\TernaryFilter::make('has_dynamic_rp')
->label('Has dynamic rich presence')
->placeholder('Any')
Expand Down

0 comments on commit 4367e24

Please sign in to comment.