Skip to content

Conversation

@juanmanzojr
Copy link
Contributor

@juanmanzojr juanmanzojr commented Nov 12, 2025

Refactors the Inactive Teacher Deletion Warning Job by extracting the core logic into dashboard/lib/inactive_teacher_deletion_warning_mailer.rb. This keeps the ApplicationJob lightweight.

Additionally, this update introduces two new options to the mailer:

dry_run: allows running the job without sending emails or writing to the database.

limit: caps the number of teachers processed in a single run.

Links

@juanmanzojr juanmanzojr requested a review from Copilot November 12, 2025 22:56
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the inactive teacher deletion warning email functionality by extracting the business logic from an ActiveJob into a dedicated service class (InactiveTeacherDeletionWarningEmailer). The job now serves as a thin wrapper that delegates to the new service class.

Key changes:

  • Created InactiveTeacherDeletionWarningEmailer service class with configurable dry-run mode and limit parameters
  • Added batching logic (1,000 records at a time) to process teachers incrementally instead of loading all at once
  • Updated tests to test the service class directly rather than through the job

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
dashboard/lib/inactive_teacher_deletion_warning_emailer.rb New service class containing the extracted email sending logic with batching, dry-run support, and configurable limits
dashboard/app/jobs/user/inactive_teacher_deletion_warning_job.rb Simplified job that now delegates to the new emailer service class
dashboard/test/lib/services/user/inactive_teacher_deletion_warning_emailer_test.rb Updated tests to test the service class directly with new test cases for dry-run mode and metrics tracking

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

juanmanzojr and others added 3 commits November 12, 2025 14:58
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@carl-codeorg
Copy link
Contributor

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 59 to 60
rescue StandardError => exception
report_exception(exception)

Choose a reason for hiding this comment

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

P2 Badge report_exception call will raise NoMethodError

The new mailer rescues StandardError and calls report_exception, but this plain service object no longer mixes in ActiveJobReporting (where that helper lives) nor defines its own report_exception. Any runtime error during email processing will therefore trigger a NoMethodError inside the rescue block, skipping error reporting and surfacing a different exception instead.

Useful? React with 👍 / 👎.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this might be a valid comment, worth testing it out

Copy link
Contributor

Choose a reason for hiding this comment

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

Does the report_exception call still need to be removed or changed? Instead of rescuing do we just allow the error to bubble up and add rescue_from StandardError, with: :report_exception back into the ActiveJob? Haven't tested this out yet to know if it works or not.

@carl-codeorg carl-codeorg changed the base branch from staging to staging-next December 12, 2025 23:09
@juanmanzojr juanmanzojr merged commit e09a4d3 into staging-next Dec 15, 2025
3 checks passed
@juanmanzojr juanmanzojr deleted the add-dry-run-limit-inactive-teacher-mailer branch December 15, 2025 06:23
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