Toolvana: production-ready media tools platform (CodeIgniter 4)
- 134-tool registry with programmatic SEO (unique titles/H1/descriptions, JSON-LD graphs, sitemap index, canonical 301 enforcement via required filter) - DB-backed job queue (SKIP LOCKED) with drivers: Ffmpeg, Images (GD), Pdf (qpdf/gs/poppler), Youtube (thumbnails), Qr (server-side PNG) - Security: SSRF guard, MIME validation, rate limits, API-key auth, bcrypt admin login, security headers - Admin panel: dashboard, tools/categories/guides CRUD, SEO audit, analytics, job inspector with retry, system health, feature flags - Docker deployment (nginx + web/api FPM pools + scalable workers), PHPUnit suite (19 tests / 1139 assertions), PWA manifest + service worker
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Controllers\Admin;
|
||||
|
||||
use App\Libraries\Pipeline;
|
||||
use App\Models\JobModel;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
|
||||
/** Queue inspection + retry. */
|
||||
final class JobsAdmin extends AdminBase
|
||||
{
|
||||
public function index(): string
|
||||
{
|
||||
$status = (string) ($this->request->getGet('status') ?? '');
|
||||
|
||||
$jobs = model(JobModel::class)->orderBy('created_at', 'DESC')->limit(100);
|
||||
if ($status !== '' && in_array($status, ['queued', 'processing', 'completed', 'failed', 'cancelled', 'expired'], true)) {
|
||||
$jobs->where('status', $status);
|
||||
}
|
||||
|
||||
return $this->render('jobs_index', [
|
||||
'jobs' => $jobs->findAll(),
|
||||
'filter' => $status,
|
||||
'counts' => [
|
||||
'queued' => model(JobModel::class)->countQueued(),
|
||||
'processing' => model(JobModel::class)->countProcessing(),
|
||||
'failed' => model(JobModel::class)->where('status', 'failed')->countAllResults(),
|
||||
'completed' => model(JobModel::class)->where('status', 'completed')->countAllResults(),
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
public function retry(string $id): ResponseInterface
|
||||
{
|
||||
$job = model(JobModel::class)->find($id);
|
||||
if ($job === null) {
|
||||
throw new \CodeIgniter\Exceptions\PageNotFoundException();
|
||||
}
|
||||
|
||||
Pipeline::failJob($id, 'superseded by retry');
|
||||
$clone = $job;
|
||||
$clone['status'] = 'queued';
|
||||
$clone['stage'] = 'queued';
|
||||
$clone['progress'] = 0;
|
||||
$clone['attempts'] = 0;
|
||||
$clone['error'] = null;
|
||||
$clone['output_file'] = null;
|
||||
$clone['output_size'] = 0;
|
||||
$clone['created_at'] = gmdate('Y-m-d H:i:s');
|
||||
$clone['started_at'] = null;
|
||||
$clone['completed_at'] = null;
|
||||
$clone['expires_at'] = gmdate('Y-m-d H:i:s', time() + config('Site')->retentionHours * 3600);
|
||||
unset($clone['id']);
|
||||
model(JobModel::class)->insert($clone, false);
|
||||
|
||||
return redirect()->to('/admin/jobs');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user