mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
rename collection
This commit is contained in:
@@ -5,10 +5,10 @@ use Utopia\Database\Helpers\ID;
|
||||
|
||||
$logsCollection = [];
|
||||
|
||||
$logsCollection['stats'] = [
|
||||
$logsCollection['usage'] = [
|
||||
'$collection' => ID::custom(Database::METADATA),
|
||||
'$id' => ID::custom('stats'),
|
||||
'name' => 'Stats',
|
||||
'$id' => ID::custom('usage'),
|
||||
'name' => 'usage',
|
||||
'attributes' => [
|
||||
[
|
||||
'$id' => ID::custom('metric'),
|
||||
|
||||
@@ -505,9 +505,9 @@ class Usage extends Action
|
||||
foreach ($this->periods as $period => $format) {
|
||||
$time = 'inf' === $period ? null : \date($format, \time());
|
||||
$id = \md5("{$time}_{$period}_{$metric}");
|
||||
$current = $dbForLogs->getDocument('stats', $id);
|
||||
$current = $dbForLogs->getDocument('usage', $id);
|
||||
if ($current->isEmpty()) {
|
||||
$dbForLogs->createDocument('stats', new Document([
|
||||
$dbForLogs->createDocument('usage', new Document([
|
||||
'$id' => $id,
|
||||
'metric' => $metric,
|
||||
'period' => $period,
|
||||
@@ -516,7 +516,7 @@ class Usage extends Action
|
||||
]));
|
||||
Console::success('Usage logs created for metric: ' . $metric . ' period:'. $period);
|
||||
} else {
|
||||
$dbForLogs->updateDocument('stats', $id, $current->setAttribute('value', $value));
|
||||
$dbForLogs->updateDocument('usage', $id, $current->setAttribute('value', $value));
|
||||
Console::success('Usage logs updated for metric: ' . $metric . ' period:'. $period);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ class UsageDump extends Action
|
||||
);
|
||||
|
||||
$dbForLogs->createOrUpdateDocumentsWithIncrease(
|
||||
collection: 'stats',
|
||||
collection: 'usage',
|
||||
attribute: 'value',
|
||||
documents: $projectDocuments
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user