Skip to content

Conversation

DennisTemoye
Copy link
Contributor

I modified the backend documentation by removing the nestjs template from the documentation.

@DennisTemoye DennisTemoye force-pushed the feature/dennis-app-setup branch from fa65459 to fd682b3 Compare June 26, 2024 19:35
Copy link
Member

@willypelz willypelz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This have merge conflicts

@DennisTemoye
Copy link
Contributor Author

This have merge conflicts

I have resolved the conflicts. @willypelz

@@ -39,6 +39,7 @@
"@nestjs/mongoose": "^10.0.1",
"@nestjs/passport": "^10.0.2",
"@nestjs/platform-express": "^10.0.0",
"@nestjs/schedule": "^4.1.1",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DennisTemoye why do we have the nestjs/schedule brought into the code?

@willypelz
Copy link
Member

This PR is having some conflicts @DennisTemoye can you fix this and would be good to be merged.

  • [] Package-lock.json
  • [] src/users/users.controller.ts
  • [] src/users/users.service.ts

Comment on lines +331 to +376
async createNotification(
message: string,
link: string,
userIds: string[],
roles: string[],
): Promise<Notification> {
const notification = new this.notificationModel({
message,
link,
userIds,
roles,
});
return await notification.save();
}

async getNotifications(
userIds?: string[],
roles?: string[],
): Promise<Notification[]> {
const query: any = {
$or: [],
};

// If userIds are provided, add them to the query
if (userIds && userIds.length > 0) {
query.$or.push({ userIds: { $in: userIds } });
}

// If roles are provided, add them to the query
if (roles && roles.length > 0) {
query.$or.push({ roles: { $in: roles } });
}

// If no filters are provided, return an empty array or all notifications as needed
if (query.$or.length === 0) {
return []; // or return await this.notificationModel.find().lean().exec(); to fetch all
}

return await this.notificationModel.find(query).lean().exec();
}

async markAsRead(notificationId: string): Promise<Notification> {
return await this.notificationModel
.findByIdAndUpdate(notificationId, { isRead: true }, { new: true })
.lean()
.exec();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR title says modify the backend documentation, it might make sense to move this change to a separate PR or add some description on the PR on these changes and add unit test. Nicely done.

@willypelz
Copy link
Member

@DennisTemoye any update on this PR

@willypelz
Copy link
Member

@DennisTemoye, this issue remains unresolved.(Conflicts with the main branch)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants