add check for preventing duplicate emails#304
Conversation
WalkthroughThe changes enhance the email notification logic within the Changes
Possibly related PRs
Suggested labels
Poem
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (1)
wp-content/civi-extensions/goonjcustom/api/v3/Goonjcustom/CollectionCampCron.php (1)
120-127: Consider adding error logging for failed email sends.The implementation effectively prevents duplicate emails and updates the sent status after successful sending. To further improve the code, consider adding error logging for cases where email sending fails. This would help in troubleshooting and monitoring the email sending process.
Example:
if ($feedbackEmailSendResult) { // Existing code to update email sent status } else { \Civi::log()->error("Failed to send feedback email for camp ID $collectionCampId"); }Apply similar logging for the completion email sending process as well.
Also applies to: 152-159
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
- wp-content/civi-extensions/goonjcustom/api/v3/Goonjcustom/CollectionCampCron.php (4 hunks)
🔇 Additional comments (6)
wp-content/civi-extensions/goonjcustom/api/v3/Goonjcustom/CollectionCampCron.php (6)
58-58: LGTM: New fields added to prevent duplicate emails.The addition of 'Logistics_Coordination.Email_Sent' and 'Logistics_Coordination.Feedback_Email_Sent' fields in the
addSelectmethod is appropriate. These fields will be used to check if emails have already been sent, which aligns with the PR objective of preventing duplicate emails.
73-74: LGTM: Variables added to track email sent status.The introduction of
$logisticEmailSentand$feedbackEmailSentvariables is appropriate. These variables will be used to store the email sent status, which is crucial for preventing duplicate emails as per the PR objective.
112-112: LGTM: Condition added to prevent duplicate feedback emails.The addition of
!$feedbackEmailSentto the condition for sending feedback emails is correct. This ensures that feedback emails are only sent if they haven't been sent before, which directly addresses the PR objective of preventing duplicate emails.
120-127: LGTM: Feedback email sent status updated after successful sending.The addition of code to update the 'Logistics_Coordination.Feedback_Email_Sent' field to 1 after successfully sending the feedback email is appropriate. This ensures that the email sent status is accurately recorded, preventing duplicate emails in future runs. The conditional update based on successful email sending is a good practice.
144-144: LGTM: Condition added to prevent duplicate completion emails.The addition of
!$logisticEmailSentto the condition for sending completion notification emails is correct. This ensures that completion emails are only sent if they haven't been sent before, which directly addresses the PR objective of preventing duplicate emails.
152-159: LGTM: Completion email sent status updated after successful sending.The addition of code to update the 'Logistics_Coordination.Email_Sent' field to 1 after successfully sending the completion email is appropriate. This ensures that the email sent status is accurately recorded, preventing duplicate emails in future runs. The conditional update based on successful email sending is a good practice.
Summary by CodeRabbit
New Features
Bug Fixes