自动查重
This commit is contained in:
33
application/api/job/PlagiarismTriggerSimilarity.php
Normal file
33
application/api/job/PlagiarismTriggerSimilarity.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?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 的 attempt(409 时用于继续轮询 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();
|
||||
try {
|
||||
$svc->runTriggerSimilarityOnly($checkId, $ingestAttempt);
|
||||
} catch (\Throwable $e) {
|
||||
$svc->markFailed($checkId, '[similarity] ' . $e->getMessage());
|
||||
}
|
||||
$job->delete();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user