From da043fd71b808590695072e7de2cec7d09a690a3 Mon Sep 17 00:00:00 2001 From: Kekskurse Date: Thu, 21 Jan 2021 15:05:24 +0100 Subject: [PATCH] Traffic --- app/Console/Commands/CalculateTraffic.php | 28 ++++++++++++++++------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/app/Console/Commands/CalculateTraffic.php b/app/Console/Commands/CalculateTraffic.php index 2caa408..2adbae3 100644 --- a/app/Console/Commands/CalculateTraffic.php +++ b/app/Console/Commands/CalculateTraffic.php @@ -56,14 +56,26 @@ class CalculateTraffic extends Command var_dump($result); foreach ($result as $key => $trafficSize) { $split = explode("-", $key); - $traffic = Traffic::query() - ->where("tenant", "=", (int)$split[0]) - ->where("gallery", "=", (int)$split[1]) - ->where("year", "=", (int)$split[2]) - ->where("month", "=", (int)$split[3]) - ->where("day", "=", (int)$split[4]) - ->where("hour", "=", (int)$split[5]) - ->first(); + if(empty($split[1])) { + $traffic = Traffic::query() + ->where("tenant", "=", (int)$split[0]) + ->whereNull("gallery") + ->where("year", "=", (int)$split[2]) + ->where("month", "=", (int)$split[3]) + ->where("day", "=", (int)$split[4]) + ->where("hour", "=", (int)$split[5]) + ->first(); + } else { + $traffic = Traffic::query() + ->where("tenant", "=", (int)$split[0]) + ->where("gallery", "=", (int)$split[1]) + ->where("year", "=", (int)$split[2]) + ->where("month", "=", (int)$split[3]) + ->where("day", "=", (int)$split[4]) + ->where("hour", "=", (int)$split[5]) + ->first(); + } + if($traffic == null) { $traffic = new Traffic(); $traffic->tenant = $split[0];