Skip to content

Conversation

jajjibhai008
Copy link
Contributor

@jajjibhai008 jajjibhai008 commented Aug 21, 2025

Description:
JIRA-> ENT-10731

Job scheduled PR(only stage): https://github.com/edx/edx-internal/pull/13234

Jira:
ENT-XXXX

Merge checklist:

  • ./manage.py makemigrations has been run
    • Note: This must be run if you modified any models.
      • It may or may not make a migration depending on exactly what you modified, but it should still be run.

Post merge:

  • Ensure that your changes went out to the stage instance
  • Deploy to prod instance

@jajjibhai008 jajjibhai008 force-pushed the eahmadjaved/ENT-10731 branch 2 times, most recently from ba33cad to 0e41476 Compare August 22, 2025 08:10
"""

subsidy_model = apps.get_model('subsidy_request.LearnerCreditRequest')
subsidy_requests = subsidy_model.objects.filter(
Copy link
Contributor Author

@jajjibhai008 jajjibhai008 Aug 25, 2025

Choose a reason for hiding this comment

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

[Reason for re-query] The task is re-queried at execution time. Between enqueue and run, requests can be approved/closed or new ones arrive. If we “pass data” and skip the task’s query, we risk sending stale/empty or incorrect digests, and Celery retries would use outdated payloads.

tasks_enqueued = 0

for policy in policies_qs.iterator():
total_policies += 1
Copy link
Member

Choose a reason for hiding this comment

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

this can be handled outside the loop with policies_qs.count()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

policies_qs.count() runs a separate SELECT COUNT(*) query, which is why I am not using it. [Reason for current approach] We already iterate policies_qs to do the per-policy check, incrementing total_policies inside that loop costs nothing extra.

@jajjibhai008 jajjibhai008 force-pushed the eahmadjaved/ENT-10731 branch from f037af3 to 9ad8f6b Compare August 26, 2025 11:27
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.

3 participants