Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add reminders to log mentoring sessions #955

Merged
merged 2 commits into from
Aug 20, 2024

Conversation

helloanil
Copy link
Contributor

@helloanil helloanil commented Aug 18, 2024

What Github issue does this PR relate to? Insert link.

Closes #712

What should the reviewer know?

This PR implements the last two reminders of the issue #712. These are reminding mentees and mentors to log mentoring sessions, after 14 and 28 days.

Important Note: The reminders that will send after 28 days are not enabled in this PR. They are commented out. This is because this email contains a sentence like this:

A few weeks ago we already reached out to you asking whether you and your mentor *** had started the mentorship already.

Since this would be confusing to receive as the first email, I suggest merging and deploying this PR with the 14 days reminder only, and in two weeks, merging and deploying the commented part so we make sure only the mentees and mentors who received the first email will receive the second email.

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Introduced a new reminder system that sends emails to mentors and mentees who have not logged their mentoring sessions within the last two weeks.
    • Added functionality to retrieve mentorship matches and generate detailed reports of those lacking logged sessions.
  • Improvements

    • Enhanced email sending process for reminders, ensuring personalized and accurate templates are used for both mentors and mentees.
  • Chores

    • Integrated a new module to improve the capabilities of the reminder email system.

Copy link

coderabbitai bot commented Aug 18, 2024

Caution

Review failed

The pull request is closed.

Walkthrough

The recent changes enhance the ReminderEmailsController and ReminderEmailsService in a NestJS application, focusing on improving the functionality of sending reminders for mentorship sessions. The controller now actively retrieves mentorship matches lacking logged sessions from the past two weeks, while the service introduces new methods to better manage session tracking and email notifications. This update optimizes the reminders' relevance and effectiveness, encouraging greater engagement within the mentorship program.

Changes

File(s) Change Summary
apps/nestjs-api/src/reminder-emails/reminder-emails.controller.ts
apps/nestjs-api/src/reminder-emails/reminder-emails.service.ts
The controller's sendMentoringSessionsLoggingReminder method has been updated to retrieve mentorship matches from the last 14 days, improving reminder relevance. The service now includes new methods for fetching mentors and mentees without logged sessions and for sending personalized reminder emails.
apps/nestjs-api/src/reminder-emails/reminder-emails.module.ts Added ConMentoringSessionsModule to ReminderEmailsModule, enhancing its functionality to utilize services from the new module.

Sequence Diagram(s)

sequenceDiagram
    participant C as ReminderEmailsController
    participant S as ReminderEmailsService
    participant M as ConMentoringSessionsService

    C->>S: sendMentoringSessionsLoggingReminder()
    S->>M: getMentorsAndMenteesWithoutMentoringSessionsLogged({ mentorshipMatchAgeInDays: 14 })
    M-->>S: Return mentorship matches
    S->>C: Check mentorship matches
    alt Matches found
        S->>S: sendLogMentoringSessionsReminder(details)
        S-->>C: Reminders sent
    else No matches
        S-->>C: No reminders needed
    end
Loading

Assessment against linked issues

Objective Addressed Explanation
Reminder to Mentors to Log-in Mentoring Sessions (Priority 5) (Issue #712) Only reminders for mentees were addressed.
Reminder to Mentees about Logging Mentoring Sessions (Priority 6) (Issue #712) Mentee reminders were not implemented.

Poem

🐇 In the fields of mentorship, we play,
With emails sent to brighten the day.
Two weeks have passed, the time's just right,
To remind our friends, with a hop and a light.
So let’s cheer for the changes, oh so grand,
Together we thrive, hand in hand! 🌼


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between d128def and 6a4032b.

Files selected for processing (3)
  • apps/nestjs-api/src/reminder-emails/reminder-emails.controller.ts (1 hunks)
  • apps/nestjs-api/src/reminder-emails/reminder-emails.module.ts (2 hunks)
  • apps/nestjs-api/src/reminder-emails/reminder-emails.service.ts (4 hunks)
Additional comments not posted (5)
apps/nestjs-api/src/reminder-emails/reminder-emails.module.ts (1)

Line range hint 3-15: LGTM! The module import is correctly added.

The addition of ConMentoringSessionsModule to the imports array is appropriate and enhances the functionality of the ReminderEmailsModule.

apps/nestjs-api/src/reminder-emails/reminder-emails.controller.ts (2)

178-203: LGTM! The reminder logic is well-implemented.

The sendMentoringSessionsLoggingReminder method effectively retrieves and processes mentorship matches for sending reminders. The use of Object.keys is an efficient way to check for entries.


185-218: Verify the commented-out code for future implementation.

The commented-out code for the 28-day reminder is a planned feature. Ensure that it is correctly implemented and tested when activated.

Verification successful

Commented-out code for 28-day reminder is correctly structured and ready for future implementation.

The code for the 28-day reminder is present and follows the same structure as the 14-day reminder. It should be uncommented and merged according to the TODO comments when ready.

  • Location: apps/nestjs-api/src/reminder-emails/reminder-emails.controller.ts
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the commented-out 28-day reminder code for future implementation.

# Test: Check for the presence of the commented-out code. Expect: Code should be present and correctly structured.
rg --type js --context 5 'mentorshipMatchesWithMentorAndMenteeDetails_4weeks'

Length of output: 77


Script:

#!/bin/bash
# Searching for the commented-out 28-day reminder code with a broader context
rg --type ts --context 10 'mentorshipMatchesWithMentorAndMenteeDetails_4weeks'

Length of output: 4663

apps/nestjs-api/src/reminder-emails/reminder-emails.service.ts (2)

223-323: LGTM! The method for retrieving mentorship matches is well-implemented.

The getMentorsAndMenteesWithoutMentoringSessionsLogged method efficiently retrieves and processes mentorship matches and profiles. The use of lodash for filtering and transforming data is appropriate.


600-701: LGTM! The email sending logic is well-refactored.

The sendLogMentoringSessionsReminder method effectively uses email templates and personalizes the content. The refactoring improves clarity and functionality.

Copy link
Contributor

@katamatata katamatata left a comment

Choose a reason for hiding this comment

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

@helloanil, I left one comment. Otherwise, it looks good to me.

@katamatata
Copy link
Contributor

@coderabbitai review

Copy link

coderabbitai bot commented Aug 19, 2024

Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Object.keys(mentorshipMatchesWithMentorAndMenteeDetails_2weeks).length > 0
) {
// send reminder emails
Object.keys(mentorshipMatchesWithMentorAndMenteeDetails_2weeks).forEach(
Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't Object.keys(mentorshipMatchesWithMentorAndMenteeDetails_2weeks) return an array of strings?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, then if you check two lines later, I do something like this:

mentorshipMatchesWithMentorAndMenteeDetails_2weeks[key]

This is because for some reason, the lodash function I use to get mentorshipMatchesWithMentorAndMenteeDetails (transform) doesn't return an array but kind of an object. I didn't have time to dig deeper in that, but I noticed I cannot just do mentorshipMatchesWithMentorAndMenteeDetails_2weeks.forEach so I have to first iterate the keys, then use the key to obtain the value.

@helloanil helloanil merged commit 53106e4 into master Aug 20, 2024
2 checks passed
@helloanil helloanil deleted the 712-con-reminders-log-mentoring-sessions branch August 20, 2024 06:33
Copy link
Contributor

@ericbolikowski ericbolikowski left a comment

Choose a reason for hiding this comment

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

Hey! Nice stuff. I see it was already merged, I didn't have time to review until today. Posted some comments.

// { mentorshipMatchAgeInDays: 28 }
// )

if (
Copy link
Contributor

Choose a reason for hiding this comment

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

Simplify? ChatGPT offered me this:

const matches = Object.values(mentorshipMatchesWithMentorAndMenteeDetails_2weeks);

if (matches.length > 0) {
  matches.forEach(async (match) => {
    await this.reminderEmailsService.sendLogMentoringSessionsReminder(match, 14);
  });
}

@@ -217,6 +220,106 @@ export class ReminderEmailsService {
return transformedReducedMatches
}

async getMentorsAndMenteesWithoutMentoringSessionsLogged({
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks quite familiar to another PR where I offered some pseudocode to simplify. What happened to that? Is it reusable here?

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.

[CON | Automated Messages] Create new reminders for mentors & mentees for Germany and Cyberspace
3 participants