- 
                Notifications
    
You must be signed in to change notification settings  - Fork 15
 
feat: write a job to send email to admin for recent opened learner cr… #822
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
ba33cad    to
    0e41476      
    Compare
  
    | """ | ||
| 
               | 
          ||
| subsidy_model = apps.get_model('subsidy_request.LearnerCreditRequest') | ||
| subsidy_requests = subsidy_model.objects.filter( | 
There was a problem hiding this comment.
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.
0e41476    to
    f037af3      
    Compare
  
    | tasks_enqueued = 0 | ||
| 
               | 
          ||
| for policy in policies_qs.iterator(): | ||
| total_policies += 1 | 
There was a problem hiding this comment.
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()
There was a problem hiding this comment.
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.
        
          
                ...rise_access/apps/subsidy_request/management/commands/send_learner_credit_bnr_daily_digest.py
              
                Outdated
          
            Show resolved
            Hide resolved
        
      f037af3    to
    9ad8f6b      
    Compare
  
    
Description:
JIRA-> ENT-10731
Job scheduled PR(only stage): https://github.com/edx/edx-internal/pull/13234
Jira:
ENT-XXXX
Merge checklist:
./manage.py makemigrationshas been runPost merge: