Browse Source

Exclude customers from overview if they are hidden from map overview

Alan Lam 5 năm trước cách đây
mục cha
commit
0b982c6b64
2 tập tin đã thay đổi với 16 bổ sung và 1 xóa
  1. 6 0
      engine/constraint.php
  2. 10 1
      views/overview.php

+ 6 - 0
engine/constraint.php

@@ -36,6 +36,12 @@ class Constraint {
 		return $constraint;
 	}
 
+	public static function notIn(array $values): Constraint {
+		$constraint = new Constraint("NOT_IN");
+		$constraint->setValues(...$values);
+		return $constraint;
+	}
+
 	/**
 	 * Constraint constructor.
 	 * @param string $type

+ 10 - 1
views/overview.php

@@ -1,4 +1,5 @@
-<?php
+<?php /** @noinspection PhpUnhandledExceptionInspection */
+
 /**
  * @var string $page_title
  * @var array $ranges
@@ -6,6 +7,12 @@
 
 use Carbon\CarbonImmutable;
 
+$exclude_customers = Customer::query(["show_in_map_overview" => 0]);
+$exclude_customer_ids = array_column($exclude_customers, "id");
+
+$exclude_projects = Project::query(["customer_id" => $exclude_customer_ids]);
+$exclude_project_ids = array_column($exclude_projects, "id");
+
 ?>
 <div class="container mt-3 py-4">
 
@@ -26,11 +33,13 @@ use Carbon\CarbonImmutable;
 			$dts_end = $dt_end->utc()->format("Y-m-d H:i:s");
 
 			$test_count = Test::count([
+				"project_id" => Constraint::notIn($exclude_project_ids),
 				"dts_start" => Constraint::between($dts_start, $dts_end),
 				"status" => Test::STATUS_COMPLETED
 			]);
 
 			$projects = Project::query([
+				"customer_id" => Constraint::notIn($exclude_customer_ids),
 				"dts_start" => Constraint::between($dts_start, $dts_end),
 			]);