From 077115d5dc26fd5d76593e16f29a5b6d16214932 Mon Sep 17 00:00:00 2001 From: Kuchizu Date: Wed, 6 May 2026 18:58:06 +0300 Subject: [PATCH 1/2] perf(notifier): project only notifications field when loading rules --- workers/notifier/src/index.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/workers/notifier/src/index.ts b/workers/notifier/src/index.ts index d2d17966..c629c6d5 100644 --- a/workers/notifier/src/index.ts +++ b/workers/notifier/src/index.ts @@ -193,9 +193,12 @@ export default class NotifierWorker extends Worker { */ private async getProjectNotificationRules(projectId: string): Promise { const connection = this.accountsDb.getConnection(); - const projects = connection.collection('projects'); + const projects = connection.collection<{ notifications?: Rule[] }>('projects'); - const project = await projects.findOne({ _id: new ObjectID(projectId) }); + const project = await projects.findOne( + { _id: new ObjectID(projectId) }, + { projection: { notifications: 1 } } + ); if (!project) { throw new Error('There is no project with given id'); From 72eeafb5b32e24a781eda08c7f9d8f090eee94d5 Mon Sep 17 00:00:00 2001 From: Kuchizu Date: Wed, 6 May 2026 19:02:30 +0300 Subject: [PATCH 2/2] test(notifier): update findOne assertion for projection arg --- workers/notifier/tests/worker.test.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/workers/notifier/tests/worker.test.ts b/workers/notifier/tests/worker.test.ts index 1f128ac1..dc438cd6 100644 --- a/workers/notifier/tests/worker.test.ts +++ b/workers/notifier/tests/worker.test.ts @@ -242,7 +242,10 @@ describe('NotifierWorker', () => { await worker.handle(message); - expect(dbQueryMock).toBeCalledWith({ _id: new ObjectID(message.projectId) }); + expect(dbQueryMock).toBeCalledWith( + { _id: new ObjectID(message.projectId) }, + { projection: { notifications: 1 } } + ); }); it('should close db connection on finish', async () => {