setName('kb:enqueue-recent') ->setDescription('扫描最近更新内容并写入AI知识库Redis队列') ->addOption('limit', null, Option::VALUE_OPTIONAL, '每个来源最多扫描数量', 1000) ->addOption('minutes', null, Option::VALUE_OPTIONAL, '扫描最近多少分钟更新的数据', 30); } protected function execute(Input $input, Output $output) { $limit = max(1, (int) $input->getOption('limit')); $minutes = max(1, (int) $input->getOption('minutes')); $summary = KbRedisQueueService::enqueueRecent($limit, $minutes); foreach ($summary['targets'] as $label => $target) { $output->writeln(sprintf( '[kb:enqueue-recent] %s scanned=%d queued=%d deduped=%d', $label, (int) $target['scanned'], (int) $target['queued'], (int) $target['deduped'] )); } $output->writeln(sprintf( '[kb:enqueue-recent] stream=%s scanned=%d queued=%d deduped=%d limit=%d minutes=%d', $summary['stream'], (int) $summary['scanned'], (int) $summary['queued'], (int) $summary['deduped'], (int) $summary['limit'], (int) $summary['minutes'] )); return 0; } }