added a help system, replaced the words "tenant" and "Pwa" with better alternatives. corrected and implemented cron jobs. prepared going live on a coolify-powered system.
This commit is contained in:
51
app/Console/Commands/PhotoboothIngestCommand.php
Normal file
51
app/Console/Commands/PhotoboothIngestCommand.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\Event;
|
||||
use App\Services\Photobooth\PhotoboothIngestService;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class PhotoboothIngestCommand extends Command
|
||||
{
|
||||
protected $signature = 'photobooth:ingest {--event= : Restrict ingestion to a single event ID}
|
||||
{--max-files= : Maximum files to import per event in this run}';
|
||||
|
||||
protected $description = 'Ingest pending Photobooth uploads from the FTP mount into event storage.';
|
||||
|
||||
public function handle(PhotoboothIngestService $ingestService): int
|
||||
{
|
||||
$eventId = $this->option('event');
|
||||
$maxFiles = $this->option('max-files');
|
||||
$processedTotal = 0;
|
||||
$skippedTotal = 0;
|
||||
|
||||
$query = Event::query()
|
||||
->where('photobooth_enabled', true)
|
||||
->whereNotNull('photobooth_path');
|
||||
|
||||
if ($eventId) {
|
||||
$query->whereKey($eventId);
|
||||
}
|
||||
|
||||
$query->chunkById(25, function ($events) use ($ingestService, $maxFiles, &$processedTotal, &$skippedTotal) {
|
||||
foreach ($events as $event) {
|
||||
$summary = $ingestService->ingest($event, $maxFiles ? (int) $maxFiles : null);
|
||||
$processedTotal += $summary['processed'] ?? 0;
|
||||
$skippedTotal += $summary['skipped'] ?? 0;
|
||||
|
||||
$this->line(sprintf(
|
||||
'Event #%d (%s): %d imported, %d skipped',
|
||||
$event->id,
|
||||
$event->slug ?? 'event',
|
||||
$summary['processed'] ?? 0,
|
||||
$summary['skipped'] ?? 0
|
||||
));
|
||||
}
|
||||
});
|
||||
|
||||
$this->info(sprintf('Photobooth ingest finished. Processed: %d, Skipped: %d', $processedTotal, $skippedTotal));
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user