diff --git a/app/config/collections.php b/app/config/collections.php index 47216f1c76..10b2d3b6a6 100644 --- a/app/config/collections.php +++ b/app/config/collections.php @@ -1052,7 +1052,6 @@ $auth = Config::getParam('auth', []); ], ] ], - 'stats' => [ '$collection' => ID::custom(Database::METADATA), '$id' => ID::custom('stats'), @@ -1085,7 +1084,7 @@ $auth = Config::getParam('auth', []); 'type' => Database::VAR_INTEGER, 'format' => '', 'size' => 8, - 'signed' => false, + 'signed' => true, 'required' => true, 'default' => null, 'array' => false, @@ -1113,17 +1112,6 @@ $auth = Config::getParam('auth', []); 'array' => false, 'filters' => [], ], - [ - '$id' => ID::custom('type'), - 'type' => Database::VAR_INTEGER, - 'format' => '', - 'size' => 1, - 'signed' => false, - 'required' => true, - 'default' => 0, // 0 -> count, 1 -> sum - 'array' => false, - 'filters' => [], - ], ], 'indexes' => [ [ @@ -1142,13 +1130,51 @@ $auth = Config::getParam('auth', []); ], [ '$id' => ID::custom('_key_metric_period_time'), - 'type' => Database::INDEX_KEY, + 'type' => Database::INDEX_UNIQUE, 'attributes' => ['metric', 'period', 'time'], 'lengths' => [], 'orders' => [Database::ORDER_DESC], ], ], ], + 'statsLogger' => [ + '$collection' => ID::custom(Database::METADATA), + '$id' => ID::custom('statsLogger'), + 'name' => 'StatsLogger', + 'attributes' => [ + [ + '$id' => ID::custom('time'), + 'type' => Database::VAR_DATETIME, + 'format' => '', + 'size' => 0, + 'signed' => false, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => ['datetime'], + ], + [ + '$id' => ID::custom('metrics'), + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 5012, + 'signed' => true, + 'required' => false, + 'default' => [], + 'array' => false, + 'filters' => ['json'], + ], + ], + 'indexes' => [ + [ + '$id' => ID::custom('_key_time'), + 'type' => Database::INDEX_KEY, + 'attributes' => ['time'], + 'lengths' => [], + 'orders' => [Database::ORDER_DESC], + ], + ], + ], ]; $projectCollections = array_merge([ diff --git a/app/workers/usage.php b/app/workers/usage.php index 497550dd40..0c9dcbc5aa 100644 --- a/app/workers/usage.php +++ b/app/workers/usage.php @@ -277,7 +277,8 @@ $server ])); } } catch (\Exception $e) { - console::error("[logger] " . " {DateTime::now()} " . " {$projectInternalId} " . " {$e->getMessage()}"); + $now = DateTime::now(); + console::error("[Error] " . " Time: {$now} " . " projectInternalId: {$projectInternalId}" . " File: {$e->getFile()}" . " Line: {$e->getLine()} " . " message: {$e->getMessage()}"); } finally { $pools->reclaim(); }