Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(manage): add has_box_art filter to GameResource #3125

Merged
merged 10 commits into from
Jan 31, 2025
49 changes: 2 additions & 47 deletions .github/workflows/ci.yml
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GitHub Actions decided to be combative again with pnpm, this time related to the cache.

To force it to pass, I removed the node-setup step and have the 3 Node.js tasks each do their own pnpm installs. Interestingly, this executes so fast it's actually faster than having a node-setup step.

Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -123,7 +84,6 @@ jobs:
run: ${{ matrix.command }}

node-checks:
needs: node-setup
runs-on: ubuntu-22.04
name: Node.js Checks
strategy:
Expand Down Expand Up @@ -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('{}') }}
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('duplicate_achievement_badges')
->label('Has stock/recycled achievement badges')
->placeholder('Any')
Expand Down