Files
tougao/application/api/job/PlagiarismTriggerSimilarity.php
2026-05-18 18:34:48 +08:00

35 lines
1.0 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
namespace app\api\job;
use think\queue\Job;
use app\common\PlagiarismService;
/**
* 队列任务:在 ingest 就绪后调用 PUT /similarity并入队 PlagiarismPoll。
*
* data:
* - check_id t_plagiarism_check.check_id
* - ingest_attempt 来自 PlagiarismWaitIngest 的 attempt409 时用于继续轮询 ingest
*/
class PlagiarismTriggerSimilarity
{
public function fire(Job $job, $data)
{
$checkId = isset($data['check_id']) ? (int) $data['check_id'] : 0;
$ingestAttempt = isset($data['ingest_attempt']) ? (int) $data['ingest_attempt'] : 1;
if ($checkId <= 0) {
$job->delete();
return;
}
$svc = new PlagiarismService();
$svc->log("PlagiarismTriggerSimilarity job is running");
try {
$svc->runTriggerSimilarityOnly($checkId, $ingestAttempt);
} catch (\Throwable $e) {
$svc->markFailed($checkId, '[similarity] ' . $e->getMessage());
}
$job->delete();
}
}