Skip to content

fix: Goal Reminder email - Optimization 3 - #331

Closed
rahulkanneri-2u wants to merge 1 commit into
release-ulmofrom
cosmo2-937-goal-reminder-query-less-data
Closed

fix: Goal Reminder email - Optimization 3#331
rahulkanneri-2u wants to merge 1 commit into
release-ulmofrom
cosmo2-937-goal-reminder-query-less-data

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 4, 2026 13:00

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

This PR optimizes the Goal Reminder email management command by moving several per-goal eligibility checks into a single, more selective database queryset, reducing the number of per-user queries performed while sending reminders.

Changes:

  • Pre-filters eligible CourseGoal rows using DB-level Exists checks for active enrollments and absence of downloadable certificates.
  • Computes weekly activity counts via a Subquery/Coalesce annotation and filters goals based on “days left in week” logic at the queryset level.
  • Reduces runtime overhead by parameterizing log messages, caching the current Site, using iterator(chunk_size=500), and replacing len(qs) with qs.count().

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

from edx_ace.recipient import Recipient
from edx_ace.utils.signals import send_ace_message_sent_signal
from common.djangoapps.student.models import CourseEnrollment
from lms.djangoapps.certificates.api import get_certificate_for_user_id
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