From e7963a5b407f935700ee488de3c32474a0ca04f0 Mon Sep 17 00:00:00 2001
From: Waheed Ahmed <waheed.ahmed@arbisoft.com>
Date: Wed, 30 May 2018 15:04:15 +0500
Subject: [PATCH] Pass program UUID as resource_id to generate unique cache
 key.

Without program UUID cache key was same every time for single learner
on multiple programs and getting the same data from cache.

LEARNER-5373
---
 lms/static/sass/views/_program-details.scss             | 1 -
 openedx/core/djangoapps/credentials/tests/test_utils.py | 2 ++
 openedx/core/djangoapps/credentials/utils.py            | 7 ++++++-
 3 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/lms/static/sass/views/_program-details.scss b/lms/static/sass/views/_program-details.scss
index 228b050ceef..d4f4843e181 100644
--- a/lms/static/sass/views/_program-details.scss
+++ b/lms/static/sass/views/_program-details.scss
@@ -312,7 +312,6 @@
     .program-heading-message {
       font-weight: 300;
     }
-
   }
 
   .course-enroll-view {
diff --git a/openedx/core/djangoapps/credentials/tests/test_utils.py b/openedx/core/djangoapps/credentials/tests/test_utils.py
index 334d8816884..b23120d1dff 100644
--- a/openedx/core/djangoapps/credentials/tests/test_utils.py
+++ b/openedx/core/djangoapps/credentials/tests/test_utils.py
@@ -46,6 +46,7 @@ class TestGetCredentials(CredentialsApiConfigMixin, CacheIsolationTestCase):
             'status': 'awarded',
         }
         self.assertEqual(kwargs['querystring'], querystring)
+        self.assertIsNone(kwargs['resource_id'])
 
         self.assertEqual(actual, expected)
 
@@ -66,5 +67,6 @@ class TestGetCredentials(CredentialsApiConfigMixin, CacheIsolationTestCase):
             'program_uuid': program_uuid,
         }
         self.assertEqual(kwargs['querystring'], querystring)
+        self.assertEqual(kwargs['resource_id'], program_uuid)
 
         self.assertEqual(actual, expected)
diff --git a/openedx/core/djangoapps/credentials/utils.py b/openedx/core/djangoapps/credentials/utils.py
index be2775dd539..8a86fd40018 100644
--- a/openedx/core/djangoapps/credentials/utils.py
+++ b/openedx/core/djangoapps/credentials/utils.py
@@ -59,5 +59,10 @@ def get_credentials(user, program_uuid=None):
     api = get_credentials_api_client(user)
 
     return get_edx_api_data(
-        credential_configuration, 'credentials', api=api, querystring=querystring, cache_key=cache_key
+        credential_configuration,
+        'credentials',
+        api=api,
+        resource_id=program_uuid,
+        querystring=querystring,
+        cache_key=cache_key
     )
-- 
GitLab