自动查重
This commit is contained in:
33
application/api/job/PlagiarismWaitIngest.php
Normal file
33
application/api/job/PlagiarismWaitIngest.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?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();
|
||||
try {
|
||||
$svc->runIngestPollStep($checkId, $attempt);
|
||||
} catch (\Throwable $e) {
|
||||
$svc->markFailed($checkId, '[ingest] ' . $e->getMessage());
|
||||
}
|
||||
$job->delete();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user