error fixes

This commit is contained in:
Damodar Lohani 2022-06-14 00:40:33 +00:00
parent 05152da195
commit d39165889e
2 changed files with 4 additions and 4 deletions

View file

@ -186,7 +186,7 @@ class Usage
if ($document->isEmpty()) {
$this->database->createDocument('stats', new Document([
'$id' => $id,
'period' => $period['key'],
'period' => $period,
'time' => $time,
'metric' => $metric,
'value' => $value,
@ -199,7 +199,7 @@ class Usage
$document->setAttribute('value', $value)
);
}
$this->latestTime[$metric][$period['key']] = $time;
$this->latestTime[$metric][$period] = $time;
} catch (\Exception $e) { // if projects are deleted this might fail
if (is_callable($this->errorHandler)) {
call_user_func($this->errorHandler, "Unable to save data for project {$projectId} and metric {$metric}: {$e->getMessage()}", $e->getTraceAsString());

View file

@ -34,7 +34,7 @@ class UsageDB extends Usage
if ($document->isEmpty()) {
$this->database->createDocument('stats', new Document([
'$id' => $id,
'period' => $period['key'],
'period' => $period,
'time' => $time,
'metric' => $metric,
'value' => $value,
@ -179,7 +179,7 @@ class UsageDB extends Usage
$this->foreachDocument($projectId, 'buckets', [], function ($bucket) use (&$projectFilesCount, &$projectFilesTotal, $projectId,) {
$metric = "storage.buckets.{$bucket->getId()}.files.count";
$count = $this->count($projectId, 'buckets_' . $bucket->getInternalId(), $metric);
$count = $this->count($projectId, 'bucket_' . $bucket->getInternalId(), $metric);
$projectFilesCount += $count;
$metric = "storage.buckets.{$bucket->getId()}.files.total";