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

35 lines
929 B
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;
/**
* 队列任务:单次查询 Turnitin submission 是否解析完成ingest未完成则延迟再次入队。
*
* data:
* - check_id t_plagiarism_check.check_id
* - attempt 从 1 递增
*/
class PlagiarismWaitIngest
{
public function fire(Job $job, $data)
{
$checkId = isset($data['check_id']) ? (int) $data['check_id'] : 0;
$attempt = isset($data['attempt']) ? (int) $data['attempt'] : 1;
if ($checkId <= 0) {
$job->delete();
return;
}
$svc = new PlagiarismService();
$svc->log("PlagiarismWaitIngest job is running");
try {
$svc->runIngestPollStep($checkId, $attempt);
} catch (\Throwable $e) {
$svc->markFailed($checkId, '[ingest] ' . $e->getMessage());
}
$job->delete();
}
}