From e32e39e099c334cdf365d7e3ca9a32903a41ae36 Mon Sep 17 00:00:00 2001
From: adeelehsan <adeel.ehsan@arbisoft.com>
Date: Wed, 13 Nov 2019 22:33:33 +0500
Subject: [PATCH] Fixing notify credentials job

To save the memory get cert and grade object directly from
the db because by doing that we'll override the queryset
evaluation and object won't be cached once it has gone out
of scope.

PROD-987
---
 .../credentials/management/commands/notify_credentials.py  | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/openedx/core/djangoapps/credentials/management/commands/notify_credentials.py b/openedx/core/djangoapps/credentials/management/commands/notify_credentials.py
index c3a5f5b7365..f42314bb671 100644
--- a/openedx/core/djangoapps/credentials/management/commands/notify_credentials.py
+++ b/openedx/core/djangoapps/credentials/management/commands/notify_credentials.py
@@ -64,9 +64,10 @@ def paged_query(queryset, delay, page_size):
 
         if delay and page:
             time.sleep(delay)
-
-        for i, item in enumerate(subquery, start=1):
-            yield page_start + i, item
+        index = 0
+        for item in subquery.iterator():
+            index += 1
+            yield page_start + index, item
 
 
 class Command(BaseCommand):
-- 
GitLab