Skip to content

Commit c6245a0

Browse files
authored
feat: filter mentorships by date from (#231)
1 parent 733b841 commit c6245a0

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

src/modules/mentorships/mentorships.controller.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,9 @@ export class MentorshipsController {
312312
);
313313
}
314314

315-
const requests = await this.mentorshipsService.getAllMentorships();
315+
const requests = await this.mentorshipsService.getAllMentorships({
316+
from: request.query.from,
317+
});
316318
const mentorshipRequests = mentorshipsToDtos(requests, currentUser);
317319
return {
318320
success: true,

src/modules/mentorships/mentorships.service.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,15 @@ export class MentorshipsService {
4040
/**
4141
* Retruns all the mentorship reqeusts
4242
*/
43-
async getAllMentorships() {
44-
return this.mentorshipModel.find({}).populate('mentee').populate('mentor');
43+
async getAllMentorships({ from }: { from?: Date }) {
44+
return this.mentorshipModel
45+
.find({
46+
createdAt: {
47+
$gte: from || -1,
48+
},
49+
})
50+
.populate('mentee')
51+
.populate('mentor');
4552
}
4653

4754
/**

0 commit comments

Comments
 (0)