Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
f0d9bd5e
Commit
f0d9bd5e
authored
Apr 07, 2016
by
Zia Fazal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
data is not being cached in celery task
parent
8a78c055
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
23 deletions
+13
-23
lms/djangoapps/api_manager/courses/tasks.py
+0
-21
lms/djangoapps/api_manager/courses/views.py
+13
-2
No files found.
lms/djangoapps/api_manager/courses/tasks.py
deleted
100644 → 0
View file @
8a78c055
"""
This file contains celery tasks for api_manager courses
"""
import
sys
from
celery.task
import
task
# pylint: disable=import-error,no-name-in-module
from
django.conf
import
settings
from
django.core.cache
import
cache
@task
(
name
=
u'lms.djangoapps.api_manager.courses.tasks.cache_static_tab_content'
)
def
cache_static_tab_contents
(
cache_key
,
contents
):
"""
Caches course static tab contents.
"""
cache_expiration
=
getattr
(
settings
,
'STATIC_TAB_CONTENTS_CACHE_TTL'
,
60
*
5
)
contents_max_size_limit
=
getattr
(
settings
,
'STATIC_TAB_CONTENTS_CACHE_MAX_SIZE_LIMIT'
,
4000
)
if
not
sys
.
getsizeof
(
contents
)
>
contents_max_size_limit
:
cache
.
set
(
cache_key
,
contents
,
cache_expiration
)
lms/djangoapps/api_manager/courses/views.py
View file @
f0d9bd5e
""" API implementation for course-oriented interactions. """
""" API implementation for course-oriented interactions. """
import
sys
from
collections
import
OrderedDict
from
collections
import
OrderedDict
import
logging
import
logging
import
itertools
import
itertools
...
@@ -53,7 +54,6 @@ from api_manager.users.serializers import UserSerializer, UserCountByCitySeriali
...
@@ -53,7 +54,6 @@ from api_manager.users.serializers import UserSerializer, UserCountByCitySeriali
from
api_manager.utils
import
generate_base_uri
,
str2bool
,
get_time_series_data
,
parse_datetime
from
api_manager.utils
import
generate_base_uri
,
str2bool
,
get_time_series_data
,
parse_datetime
from
.serializers
import
CourseSerializer
from
.serializers
import
CourseSerializer
from
.serializers
import
GradeSerializer
,
CourseLeadersSerializer
,
CourseCompletionsLeadersSerializer
from
.serializers
import
GradeSerializer
,
CourseLeadersSerializer
,
CourseCompletionsLeadersSerializer
from
.tasks
import
cache_static_tab_contents
from
progress.serializers
import
CourseModuleCompletionSerializer
from
progress.serializers
import
CourseModuleCompletionSerializer
...
@@ -383,11 +383,22 @@ def _get_static_tab_contents(request, course, tab):
...
@@ -383,11 +383,22 @@ def _get_static_tab_contents(request, course, tab):
contents
=
cache
.
get
(
cache_key
)
contents
=
cache
.
get
(
cache_key
)
if
contents
is
None
:
if
contents
is
None
:
contents
=
get_static_tab_contents
(
request
,
course
,
tab
,
wrap_xmodule_display
=
False
)
contents
=
get_static_tab_contents
(
request
,
course
,
tab
,
wrap_xmodule_display
=
False
)
cache_static_tab_contents
.
delay
(
cache_key
,
contents
)
_cache_static_tab_contents
(
cache_key
,
contents
)
return
contents
return
contents
def
_cache_static_tab_contents
(
cache_key
,
contents
):
"""
Caches course static tab contents.
"""
cache_expiration
=
getattr
(
settings
,
'STATIC_TAB_CONTENTS_CACHE_TTL'
,
60
*
5
)
contents_max_size_limit
=
getattr
(
settings
,
'STATIC_TAB_CONTENTS_CACHE_MAX_SIZE_LIMIT'
,
4000
)
if
not
sys
.
getsizeof
(
contents
)
>
contents_max_size_limit
:
cache
.
set
(
cache_key
,
contents
,
cache_expiration
)
class
CourseContentList
(
SecureAPIView
):
class
CourseContentList
(
SecureAPIView
):
"""
"""
**Use Case**
**Use Case**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment