Skip to content

Commit

Permalink
Plagiarism: Compilatio: fix analyses API query to work with all servi…
Browse files Browse the repository at this point in the history
…ces and contracts for compilatio - refs BT#22318
  • Loading branch information
NicoDucou committed Dec 31, 2024
1 parent 8f92e15 commit 18b2131
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions main/inc/lib/Compilatio.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,13 +191,26 @@ public function getDoc(string $documentId): array
$documentInfo = [
'report_url' => $dataDocument['report_url'],
];

if (isset($dataDocument['analyses']['anasim']['state'])) {
$documentInfo['analysis_status'] = $dataDocument['analyses']['anasim']['state'];
// anasim analyse type is applied for services Magister and Copyright
// anasim-premium analyse type is applied for services Magister+ and Copyright+
$anasim = 'anasim';
if (isset($dataDocument['analyses']['anasim-premium'])) {
$anasim = 'anasim-premium';
if (isset($dataDocument['analyses']['anasim'])) {
if (isset($dataDocument['analyses']['anasim']['creation_launch_date']) && isset($dataDocument['analyses']['anasim-premium']['creation_launch_date'])) {
// if the 2 analyses type exist (which could happen technically but would be exceptional) then we present the most recent one.
if ($dataDocument['analyses']['anasim']['creation_launch_date'] > $dataDocument['analyses']['anasim-premium']['creation_launch_date']) {
$anasim = 'anasim';
}
}
}
}

if (isset($dataDocument['light_reports']['anasim']['scores']['global_score_percent'])) {
$documentInfo['report_percent'] = $dataDocument['light_reports']['anasim']['scores']['global_score_percent'];
if (isset($dataDocument['analyses'][$anasim]['state'])) {
$documentInfo['analysis_status'] = $dataDocument['analyses'][$anasim]['state'];
}

if (isset($dataDocument['light_reports'][$anasim]['scores']['global_score_percent'])) {
$documentInfo['report_percent'] = $dataDocument['light_reports'][$anasim]['scores']['global_score_percent'];
}

return $documentInfo;
Expand Down

0 comments on commit 18b2131

Please sign in to comment.