<?php
namespace EasyChat\Library\Queue\Jobs;

use EasyChat\Library\ResponseTimeMetrics;

class ResponseTimeMetricsBackfillJob {
    private $registry;

    public function __construct($registry) {
        $this->registry = $registry;
    }

    public function handle(array $payload): void {
        $last_message_id = isset($payload['last_message_id']) ? (int)$payload['last_message_id'] : 0;
        $batch_size = isset($payload['batch_size']) ? (int)$payload['batch_size'] : 500;

        $metrics = new ResponseTimeMetrics($this->registry);
        $metrics->backfillBatch($last_message_id, $batch_size);
    }
}
