瀏覽代碼

Fix issue where unverified tests are included in marker data

Alan Lam 2 年之前
父節點
當前提交
4010158596
共有 3 個文件被更改,包括 9 次插入 和 2 次删除
  1. 1 1
      controllers/customer_ajax.php
  2. 3 1
      controllers/map_overview_ajax.php
  3. 5 0
      engine/helpers/location_helper.php

+ 1 - 1
controllers/customer_ajax.php

@@ -47,7 +47,7 @@ switch($action) {
 
 		$locations = $search->run();
 
-		$output = LocationHelper::getMarkerDataForLocations($locations, $min_date, $max_date);
+		$output = LocationHelper::getMarkerDataForLocations($locations, $min_date, $max_date, ["user" => $user]);
 
 		JSON::success([
 			"locations" => $output

+ 3 - 1
controllers/map_overview_ajax.php

@@ -8,6 +8,8 @@ use Helpers\LocationHelper;
 
 $date_format = "/^2\d{3}-[01]\d-[0-3]\d$/";
 
+$user = Core::$user;
+
 JSON::header();
 
 $submit = http::value("submit");
@@ -17,7 +19,7 @@ if($submit) {
 
 		Core::validateCSRFToken($submit);
 
-		$options = [];
+		$options = ["user" => $user];
 
 		$filter = http::value("filter");
 		if($filter === "untested-only") {

+ 5 - 0
engine/helpers/location_helper.php

@@ -29,6 +29,7 @@ class LocationHelper {
 
 		$failed_only = $options["failed_only"] ?? false;
 		$untested_only = $options["untested_only"] ?? false;
+		$user = $options["user"] ?? null;
 
 		$location = reset($locations);
 
@@ -54,6 +55,10 @@ class LocationHelper {
 			"location_id" => array_column($locations, "id")
 		];
 
+		if($user && $user->level <= User::LEVEL_CUSTOMER) {
+			$nvp["status"] = Test::STATUS_COMPLETED;
+		}
+
 		if($min_date && $max_date) {
 			if(preg_match(self::DATE_FORMAT, $min_date) && preg_match(self::DATE_FORMAT, $max_date)) {
 				$min_dts = $min_date;