From d1f37ae6dcd32720fbf5bc0be82534bd44104240 Mon Sep 17 00:00:00 2001 From: mikael-zakaria Date: Sun, 2 Feb 2025 23:05:59 +0800 Subject: [PATCH] fix subtest depth --- app/Controllers/API_Results.php | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/app/Controllers/API_Results.php b/app/Controllers/API_Results.php index 1f4a1e4..45ae580 100644 --- a/app/Controllers/API_Results.php +++ b/app/Controllers/API_Results.php @@ -87,7 +87,8 @@ left join cmod.dbo.CM_TM_TESTS ct on ct.HISCODE=m.HISCODE and ct.REQID=cq.REQID left join cmod.dbo.CM_DICT_TUBES tub on tub.TUBEID=m.TUBEID where r.ACCESSNUMBER='$accessnumber' ORDER BY t.TESTORDER"; $query = $db->query($sql); - $test_results = $query->getResultArray(); + $test_results = $query->getResultArray(); + $d0=-1; $d1=-1; $d2=-1; $d3=-1; foreach ($test_results as $result) { $refftestid = trim($result['REFFTESTID']); $testorder = $result['TESTORDER']; @@ -126,21 +127,22 @@ where r.ACCESSNUMBER='$accessnumber' ORDER BY t.TESTORDER"; "test_unit"=> "$testunit", "test_reff" => "$testreff", "test_summary"=> "$testsum", - //"subtest_results" => [], - ]; + //"debug" => "d0=$d0 d1=$d1 d2=$d2", + ]; if ( $depth == 0 || $depth == '' ) { // depth 0 - if(isset($d0)) { $d0++; } else { $d0 = 0; } - $d1=0; + $d0++; + $d1=-1; $json['test_results'][] = $data; } else if ($depth == 1) { // depth 1 - if(isset($d1)) { $d1++; } - $d2=0; + $d1++; + $d2=-1; $json['test_results'][$d0]['subtest_results'][] = $data; - } else if ($depth == 2) { // depth 2 - if(isset($d2)) { $d2++; } - $d3=0; + } else if ($depth == 2) { // depth 2 + $d2++; + $d3=-1; $json['test_results'][$d0]['subtest_results'][$d1]['subtest_results'][] = $data; } + } return $json; }