Skip to content
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

fix: caching was removed #33617

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions lms/djangoapps/grades/rest_api/v1/gradebook_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from functools import wraps

from django.contrib.auth import get_user_model
from django.core.cache import cache
from django.db.models import Case, Exists, F, OuterRef, Q, When
from django.urls import reverse
from django.utils.translation import gettext_lazy as _
Expand Down Expand Up @@ -670,22 +669,16 @@ def get(self, request, course_key): # lint-amnesty, pylint: disable=too-many-st
serializer = StudentGradebookEntrySerializer(entries, many=True)
return self.get_paginated_response(serializer.data, **users_counts)

def _get_user_count(self, query_args, cache_time=3600, annotations=None):
def _get_user_count(self, query_args, annotations=None):
"""
Return the user count for the given query arguments to CourseEnrollment.

caches the count for cache_time seconds.
"""
queryset = CourseEnrollment.objects
if annotations:
queryset = queryset.annotate(**annotations)
queryset = queryset.filter(*query_args)

cache_key = 'usercount.%s' % queryset.query
user_count = cache.get(cache_key, None)
if user_count is None:
user_count = queryset.count()
cache.set(cache_key, user_count, cache_time)
user_count = queryset.count()

return user_count

Expand Down
Loading