Skip to content

Chunked dispatch of campaign email jobs and id-based job payloads#1

Merged
ProgrammerHasan merged 1 commit into
mainfrom
codex/improve-campaign-email-sending
Feb 6, 2026
Merged

Chunked dispatch of campaign email jobs and id-based job payloads#1
ProgrammerHasan merged 1 commit into
mainfrom
codex/improve-campaign-email-sending

Conversation

@ProgrammerHasan

Copy link
Copy Markdown
Owner

Motivation

  • Avoid loading all campaign recipients into memory when sending a campaign to improve scalability and memory usage.
  • Reduce job payload size and avoid serializing whole Eloquent models into queued jobs to prevent stale/large data being serialized.
  • Make job execution more robust by loading current recipient relations at run-time and safely handling missing recipients.

Description

  • Changed SendCampaignEmailJob to accept an int $recipientId instead of a CampaignRecipient model and to load the CampaignRecipient with campaign and contact relations inside handle, returning early if the recipient no longer exists.
  • Updated CampaignService::send to iterate recipients using ->recipients()->select('id')->chunkById(100, ...) and dispatch SendCampaignEmailJob with recipientId: $recipient->id to avoid loading all recipients at once.
  • Kept existing status updates and logging behavior in the job (Status::SENT / Status::FAILED) while preserving the Mail::to(...)->send(...) call and error handling.

Testing

  • No automated tests were executed for this change.

Codex Task

@ProgrammerHasan ProgrammerHasan merged commit 27c881f into main Feb 6, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant