Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/young-humans-stare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@rocket.chat/models': patch
Comment thread
ricardogarim marked this conversation as resolved.
'@rocket.chat/meteor': patch
Comment thread
ricardogarim marked this conversation as resolved.
---

Adds automatic cleanup of statistics collection with 1-year retention via TTL index.
5 changes: 4 additions & 1 deletion packages/models/src/models/Statistics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ export class StatisticsRaw extends BaseRaw<IStats> implements IStatisticsModel {
}

protected override modelIndexes(): IndexDescription[] {
return [{ key: { createdAt: -1 } }];
return [
{ key: { createdAt: -1 } },
{ key: { createdAt: 1 }, expireAfterSeconds: 365 * 24 * 60 * 60 }, // expire after 1 year
];
}

async findLast(): Promise<IStats> {
Expand Down
Loading