Skip to content

fix: Optimized goal_reminder_email query - Part 2 - #322

Closed
rahulkanneri-2u wants to merge 5 commits into
release-ulmofrom
COSMO2-937-goal-reminder-optimization
Closed

fix: Optimized goal_reminder_email query - Part 2#322
rahulkanneri-2u wants to merge 5 commits into
release-ulmofrom
COSMO2-937-goal-reminder-optimization

Conversation

@rahulkanneri-2u

Copy link
Copy Markdown

Description

Describe what this pull request changes, and why. Include implications for people using this change.
Design decisions and their rationales should be documented in the repo (docstring / ADR), per
OEP-19, and can be
linked here.

Useful information to include:

  • Which edX user roles will this change impact? Common user roles are "Learner", "Course Author",
    "Developer", and "Operator".
  • Include screenshots for changes to the UI (ideally, both "before" and "after" screenshots, if applicable).
  • Provide links to the description of corresponding configuration changes. Remember to correctly annotate these
    changes.

Supporting information

Link to other information about the change, such as Jira issues, GitHub issues, or Discourse discussions.
Be sure to check they are publicly readable, or if not, repeat the information here.

Testing instructions

Please provide detailed step-by-step instructions for testing this change.

Deadline

"None" if there's no rush, or provide a specific date or event (and reason) if there is one.

Other information

Include anything else that will help reviewers and consumers understand the change.

  • Does this change depend on other changes elsewhere?
  • Any special concerns or limitations? For example: deprecations, migrations, security, or accessibility.
  • If your database migration can't be rolled back easily.

Copilot AI review requested due to automatic review settings June 2, 2026 08:50
@rahulkanneri-2u rahulkanneri-2u changed the title Cosmo2 937 goal reminder optimization fix: Optimized goal_reminder_email query - Part 2 Jun 2, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Optimizes the goal_reminder_email management command to reduce memory usage and pre-filter goals at the database level. An Exists subquery now eliminates CourseGoal rows whose users have no eligible active enrollment, the queryset is streamed via iterator() instead of being fully materialized, and len() calls are replaced with count(). The per-goal timezone check is moved to the start of handle_goal so the cheapest filter runs first, and Site.objects.get_current() is hoisted out of the loop.

Changes:

  • Push enrollment eligibility filtering into a DB-level Exists subquery and stream results with iterator(chunk_size=500) + count() instead of len().
  • Move the timezone window check to the top of handle_goal to short-circuit early.
  • Hoist Site.objects.get_current() out of the per-goal loop.

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

Copilot AI review requested due to automatic review settings June 2, 2026 09:18

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings June 2, 2026 09:37

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

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