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
7 changes: 5 additions & 2 deletions workers/notifier/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,12 @@ export default class NotifierWorker extends Worker {
*/
private async getProjectNotificationRules(projectId: string): Promise<Rule[]> {
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');
Expand Down
5 changes: 4 additions & 1 deletion workers/notifier/tests/worker.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
Loading