'array', 'duration' => 'float', ]; const STAGE_UPLOAD = 'upload'; const STAGE_EXTRACT = 'extract'; const STAGE_CHUNK = 'chunk'; const STAGE_EMBED = 'embed'; const STAGE_QDRANT = 'qdrant_sync'; const STAGE_COMPLETE = 'completed'; const STAGE_FAILED = 'failed'; const STATUS_STARTED = 'started'; const STATUS_COMPLETED = 'completed'; const STATUS_FAILED = 'failed'; public function scopeForRecord(Builder $query, string $type, int $id): Builder { return $query->where('processable_type', $type) ->where('processable_id', $id); } /** * Helper untuk log processing dengan masa */ public static function record( string $type, int $id, string $stage, string $status, ?string $message = null, ?array $metadata = null, ?float $duration = null ): self { return static::create([ 'processable_type' => $type, 'processable_id' => $id, 'stage' => $stage, 'status' => $status, 'message' => $message, 'metadata' => $metadata, 'duration' => $duration, ]); } }