Skip to content

fix(*) remove email api#483

Merged
nishant22029 merged 1 commit intodevelopfrom
fix/remove-email-api-query
Nov 22, 2024
Merged

fix(*) remove email api#483
nishant22029 merged 1 commit intodevelopfrom
fix/remove-email-api-query

Conversation

@nishant22029
Copy link
Copy Markdown
Collaborator

@nishant22029 nishant22029 commented Nov 22, 2024

  • remove email activity and update varaible name

Summary by CodeRabbit

  • New Features
    • Streamlined email sending process for volunteer induction activities.
    • Enhanced error tracking with improved logging for state not found scenarios.
  • Bug Fixes
    • Removed checks for previously sent emails, which may lead to duplicate sends.
    • Updated email status handling to ensure accurate tracking of email activities.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Nov 22, 2024

Walkthrough

The changes in the InductionService class within Civi/InductionService.php involve the removal of email-sending checks to streamline the process. Methods such as sendFollowUpEmails, sendInductionRescheduleEmail, and sendRemainderEmails no longer verify if emails were previously sent, which may result in duplicates. Additionally, logging enhancements and new checks for the entryURL parameter in the hasIndividualChangedToVolunteer method have been implemented to improve error tracking and control over method execution.

Changes

File Path Change Summary
wp-content/civi-extensions/goonjcustom/Civi/InductionService.php - Removed checks for previously sent emails in sendFollowUpEmails, sendInductionRescheduleEmail, and sendRemainderEmails methods.
- Updated sendInductionRescheduleEmail to mark activity status as 'To be scheduled' if no email has been sent.
- Enhanced logging in createInductionForTransitionedVolunteer for missing state cases.
- Added check for entryURL in hasIndividualChangedToVolunteer to prevent processing if it contains '/contribute'.
- Method signatures updated for sendInductionEmailToVolunteer and sendInductionEmailForTransitionedVolunteer.

Possibly related PRs

Suggested reviewers

  • tarunnjoshi

Poem

In the land of code where emails fly,
Changes were made, oh my, oh my!
Duplicates gone, with a logging cheer,
Inductions now flow, let’s give a cheer!
With checks in place, and status set right,
The InductionService shines so bright! 🌟


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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 using 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.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

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
Copy Markdown

@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: 1

🧹 Outside diff range and nitpick comments (4)
wp-content/civi-extensions/goonjcustom/Civi/InductionService.php (4)

Line range hint 509-511: Fix array comparison syntax error

The array comparison syntax is incorrect and will cause unexpected behavior.

-    if ($contacts['contact_sub_type' === 'Volunteer']) {
+    if (in_array('Volunteer', $contacts['contact_sub_type'] ?? [])) {

Line range hint 392-397: Extract duplicate template fetching logic

The pattern for fetching message templates is repeated across multiple methods. Consider extracting this into a reusable method.

+  private static function getMessageTemplate($templatePattern) {
+    return MessageTemplate::get(FALSE)
+      ->addSelect('id', 'msg_subject')
+      ->addWhere('msg_title', 'LIKE', $templatePattern)
+      ->setLimit(1)
+      ->execute()
+      ->single();
+  }

Also applies to: 576-582, 783-789


Line range hint 849-922: Simplify induction type determination logic

The fetchTypeOfInduction method is complex and hard to maintain. Consider:

  1. Using configuration for state/city mappings
  2. Extracting the city formatting logic
  3. Simplifying the nested conditions
+  private static $OFFLINE_INDUCTION_CITIES = ['patna', 'ranchi', 'bhubaneshwar'];
+  private static $MIXED_INDUCTION_STATES = ['Bihar', 'Jharkhand', 'Orissa'];
+
+  private static function formatCity($city) {
+    return ucwords(strtolower($city ?? ''));
+  }

Line range hint 12-24: Consider using enum for activity statuses

The class uses multiple string constants for activity statuses. Consider using an enum (or class constants) to prevent typos and improve maintainability.

+  private static $ACTIVITY_STATUS = [
+    'TO_BE_SCHEDULED' => 'To be scheduled',
+    'SCHEDULED' => 'Scheduled',
+    'COMPLETED' => 'Completed',
+    'CANCELLED' => 'Cancelled',
+    'NO_SHOW' => 'No_show',
+  ];
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between b3fc697 and 2b1332c.

📒 Files selected for processing (1)
  • wp-content/civi-extensions/goonjcustom/Civi/InductionService.php (1 hunks)

$contacts = Contact::get(FALSE)
->addSelect('Individual_fields.Induction_Reschedule_Email_Sent')
->addWhere('id', '=',$scheduledInductionActivity['source_contact_id'] )
->addWhere('id', '=',$activity['source_contact_id'] )
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix indentation

The line is incorrectly indented, breaking the consistent code style.

-          ->addWhere('id', '=',$activity['source_contact_id'] )
+        ->addWhere('id', '=', $activity['source_contact_id'])
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
->addWhere('id', '=',$activity['source_contact_id'] )
->addWhere('id', '=', $activity['source_contact_id'])

@nishant22029 nishant22029 merged commit b45f834 into develop Nov 22, 2024
@nishant22029 nishant22029 deleted the fix/remove-email-api-query branch November 22, 2024 09:32
@coderabbitai coderabbitai bot mentioned this pull request Dec 4, 2024
@coderabbitai coderabbitai bot mentioned this pull request Dec 16, 2024
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.

2 participants