From f2abce53cb8e74a3974f1372d153d5ef5dec7ba8 Mon Sep 17 00:00:00 2001 From: Nimisha Asthagiri Date: Tue, 7 Feb 2017 20:07:04 -0500 Subject: [PATCH] request-cache grades feature flag to avoid 400+ memcached hits --- lms/djangoapps/grades/config/models.py | 2 ++ lms/djangoapps/grades/config/tests/utils.py | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lms/djangoapps/grades/config/models.py b/lms/djangoapps/grades/config/models.py index dff819d7ed..5d1b15fe44 100644 --- a/lms/djangoapps/grades/config/models.py +++ b/lms/djangoapps/grades/config/models.py @@ -6,6 +6,7 @@ from config_models.models import ConfigurationModel from django.conf import settings from django.db.models import BooleanField from openedx.core.djangoapps.xmodule_django.models import CourseKeyField +from request_cache.middleware import request_cached class PersistentGradesEnabledFlag(ConfigurationModel): @@ -19,6 +20,7 @@ class PersistentGradesEnabledFlag(ConfigurationModel): enabled_for_all_courses = BooleanField(default=False) @classmethod + @request_cached def feature_enabled(cls, course_id=None): """ Looks at the currently active configuration model to determine whether diff --git a/lms/djangoapps/grades/config/tests/utils.py b/lms/djangoapps/grades/config/tests/utils.py index a4cccf6701..f01e3d920b 100644 --- a/lms/djangoapps/grades/config/tests/utils.py +++ b/lms/djangoapps/grades/config/tests/utils.py @@ -2,8 +2,9 @@ Provides helper functions for tests that want to configure flags related to persistent grading. """ -from lms.djangoapps.grades.config.models import PersistentGradesEnabledFlag, CoursePersistentGradesFlag from contextlib import contextmanager +from lms.djangoapps.grades.config.models import PersistentGradesEnabledFlag, CoursePersistentGradesFlag +from request_cache.middleware import RequestCache @contextmanager @@ -18,6 +19,7 @@ def persistent_grades_feature_flags( as they need to set the global setting and the course-specific setting for a single course. """ + RequestCache.clear_request_cache() PersistentGradesEnabledFlag.objects.create(enabled=global_flag, enabled_for_all_courses=enabled_for_all_courses) if course_id: CoursePersistentGradesFlag.objects.create(course_id=course_id, enabled=enabled_for_course)