-
-
Notifications
You must be signed in to change notification settings - Fork 320
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add check for number of sizevariants without sizes. (#2252)
* more checks * Update app/Actions/Diagnostics/Pipes/Checks/CountSizeVariantsCheck.php Co-authored-by: Kamil Iskra <[email protected]> --------- Co-authored-by: Kamil Iskra <[email protected]>
- Loading branch information
Showing
2 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
app/Actions/Diagnostics/Pipes/Checks/CountSizeVariantsCheck.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
namespace App\Actions\Diagnostics\Pipes\Checks; | ||
|
||
use App\Contracts\DiagnosticPipe; | ||
use Illuminate\Support\Facades\DB; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
/** | ||
* This checks the Database integrity. | ||
* More precisely if there are any size variants with the filesize missing. | ||
*/ | ||
class CountSizeVariantsCheck implements DiagnosticPipe | ||
{ | ||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function handle(array &$data, \Closure $next): array | ||
{ | ||
if (!Schema::hasTable('size_variants')) { | ||
return $next($data); | ||
} | ||
|
||
$num = DB::table('size_variants')->where('size_variants.filesize', '=', 0)->count(); | ||
if ($num > 0) { | ||
// @codeCoverageIgnoreStart | ||
$data[] = sprintf('Info: Found %d small images without filesizes.', $num); | ||
$data[] = sprintf(' You can use `php artisan lychee:variant_filesize %d` to compute them.', $num); | ||
// @codeCoverageIgnoreEnd | ||
} | ||
|
||
return $next($data); | ||
} | ||
} |