diff --git a/metager/app/Http/Controllers/AdminInterface.php b/metager/app/Http/Controllers/AdminInterface.php index f6970525a80e39de76e82afd2aa577534860c134..f8deba64a37c4ea838f1414070e4e75a477ffe74 100644 --- a/metager/app/Http/Controllers/AdminInterface.php +++ b/metager/app/Http/Controllers/AdminInterface.php @@ -56,7 +56,7 @@ class AdminInterface extends Controller public function getCountData(Request $request) { $date = $request->input('date', ''); - $date = Carbon::createFromFormat("Y-m-d H:i:s", "$date 00:00:00"); + $date = Carbon::createFromFormat("Y-m-d H:i:s", "$date 00:00:00", 'UTC'); if ($date === false) { abort(404); } @@ -66,7 +66,7 @@ class AdminInterface extends Controller $connection = DB::connection("logs"); $log_summary = $connection ->table( - $connection->table("logs")->select(["*"])->whereRaw("(time at time zone 'UTC') between '" . $date->format("Y-m-d") . " 00:00:00' and '" . $date->format("Y-m-d") . " 23:59:59'"), + $connection->table("logs_partitioned")->select(["*"])->whereRaw("time between '" . $date->format("Y-m-d") . " 00:00:00' and '" . $date->format("Y-m-d") . " 23:59:59'"), "data" ) ->select(DB::raw("date_trunc('hour', data.time) AS timestamp, count(*)")) @@ -89,9 +89,9 @@ class AdminInterface extends Controller "until_now" => 0 ]; - $now = Carbon::now(); + $now = Carbon::now("UTC"); foreach ($log_summary as $entry) { - $time = Carbon::createFromFormat("Y-m-d H:i:sO", $entry->timestamp); + $time = Carbon::createFromFormat("Y-m-d H:i:s", $entry->timestamp, "UTC"); $time->day(1)->year($now->year)->month($now->month)->day($now->day); $result["total"] += $entry->count; if ($time->isBefore($now)) { diff --git a/metager/app/QueryLogger.php b/metager/app/QueryLogger.php index 8b76e64a495ff2be2accd15b25cd7272a5c16250..771172561e5947bd45b11e095a82c59c10171c7c 100644 --- a/metager/app/QueryLogger.php +++ b/metager/app/QueryLogger.php @@ -139,7 +139,7 @@ class QueryLogger } if (sizeof($insert_array) > 0) { - return DB::connection("logs")->table("logs")->insert($insert_array); + return DB::connection("logs")->table("logs_partitioned")->insert($insert_array); } return false; } @@ -156,8 +156,8 @@ class QueryLogger $connection = DB::connection("logs"); $since->setTimezone("UTC"); // We will query in UTC time - $queries = $connection->table("logs") - ->whereRaw("(time at time zone 'UTC') > '" . $since->format("Y-m-d H:i:s") . "'") + $queries = $connection->table("logs_partitioned") + ->whereRaw("time > '" . $since->format("Y-m-d H:i:s") . "'") ->orderBy("time", "asc") ->get(); return $queries;