Skip to content

Commit f6dfe05

Browse files
authored
Merge branch 'master' into feat/grouper-slow-diagnostics
2 parents e81f695 + 5885e77 commit f6dfe05

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

workers/notifier/src/index.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,12 @@ export default class NotifierWorker extends Worker {
193193
*/
194194
private async getProjectNotificationRules(projectId: string): Promise<Rule[]> {
195195
const connection = this.accountsDb.getConnection();
196-
const projects = connection.collection('projects');
196+
const projects = connection.collection<{ notifications?: Rule[] }>('projects');
197197

198-
const project = await projects.findOne({ _id: new ObjectID(projectId) });
198+
const project = await projects.findOne(
199+
{ _id: new ObjectID(projectId) },
200+
{ projection: { notifications: 1 } }
201+
);
199202

200203
if (!project) {
201204
throw new Error('There is no project with given id');

workers/notifier/tests/worker.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,10 @@ describe('NotifierWorker', () => {
242242

243243
await worker.handle(message);
244244

245-
expect(dbQueryMock).toBeCalledWith({ _id: new ObjectID(message.projectId) });
245+
expect(dbQueryMock).toBeCalledWith(
246+
{ _id: new ObjectID(message.projectId) },
247+
{ projection: { notifications: 1 } }
248+
);
246249
});
247250

248251
it('should close db connection on finish', async () => {

0 commit comments

Comments
 (0)