From 2770ff911758aefd16c96846fc9628b106173388 Mon Sep 17 00:00:00 2001 From: Ricardo Garim Date: Mon, 9 Feb 2026 10:55:48 -0300 Subject: [PATCH 1/3] fix: add TTL index to statistics collection for automatic cleanup --- packages/models/src/models/Statistics.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/models/src/models/Statistics.ts b/packages/models/src/models/Statistics.ts index 8a1dae77dc76e..47ddb6a633f93 100644 --- a/packages/models/src/models/Statistics.ts +++ b/packages/models/src/models/Statistics.ts @@ -10,7 +10,10 @@ export class StatisticsRaw extends BaseRaw 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 { From e64adb7e865cfa6a1c4772b3a4fd62f1baaa2bcf Mon Sep 17 00:00:00 2001 From: Ricardo Garim Date: Mon, 9 Feb 2026 10:55:52 -0300 Subject: [PATCH 2/3] chore: add changeset --- .changeset/young-humans-stare.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/young-humans-stare.md diff --git a/.changeset/young-humans-stare.md b/.changeset/young-humans-stare.md new file mode 100644 index 0000000000000..c887f9479f673 --- /dev/null +++ b/.changeset/young-humans-stare.md @@ -0,0 +1,5 @@ +--- +'@rocket.chat/models': patch +--- + +Adds automatic cleanup of statistics collection with 1-year retention via TTL index. From 58aa7beb49f2ef1c9bc0abb16af183e2413755e0 Mon Sep 17 00:00:00 2001 From: Ricardo Garim Date: Wed, 18 Feb 2026 18:28:26 -0300 Subject: [PATCH 3/3] Apply suggestion from @sampaiodiego Co-authored-by: Diego Sampaio --- .changeset/young-humans-stare.md | 1 + 1 file changed, 1 insertion(+) diff --git a/.changeset/young-humans-stare.md b/.changeset/young-humans-stare.md index c887f9479f673..f9d113d947d64 100644 --- a/.changeset/young-humans-stare.md +++ b/.changeset/young-humans-stare.md @@ -1,5 +1,6 @@ --- '@rocket.chat/models': patch +'@rocket.chat/meteor': patch --- Adds automatic cleanup of statistics collection with 1-year retention via TTL index.