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
21bcf55d
Commit
21bcf55d
authored
Apr 09, 2015
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract _all_block_types and _all_usage_keys out of cache class
parent
4463f711
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
30 deletions
+33
-30
lms/djangoapps/courseware/model_data.py
+33
-30
No files found.
lms/djangoapps/courseware/model_data.py
View file @
21bcf55d
...
@@ -68,6 +68,36 @@ def _chunked_query(model_class, select_for_update, chunk_field, items, chunk_siz
...
@@ -68,6 +68,36 @@ def _chunked_query(model_class, select_for_update, chunk_field, items, chunk_siz
return
res
return
res
def
_all_usage_keys
(
descriptors
,
aside_types
):
"""
Return a set of all usage_ids for the `descriptors` and for
as all asides in `aside_types` for those descriptors.
"""
usage_ids
=
set
()
for
descriptor
in
descriptors
:
usage_ids
.
add
(
descriptor
.
scope_ids
.
usage_id
)
for
aside_type
in
aside_types
:
usage_ids
.
add
(
AsideUsageKeyV1
(
descriptor
.
scope_ids
.
usage_id
,
aside_type
))
return
usage_ids
def
_all_block_types
(
descriptors
,
aside_types
):
"""
Return a set of all block_types for the supplied `descriptors` and for
the asides types in `aside_types` associated with those descriptors.
"""
block_types
=
set
()
for
descriptor
in
descriptors
:
block_types
.
add
(
BlockTypeKeyV1
(
descriptor
.
entry_point
,
descriptor
.
scope_ids
.
block_type
))
for
aside_type
in
aside_types
:
block_types
.
add
(
BlockTypeKeyV1
(
XBlockAside
.
entry_point
,
aside_type
))
return
block_types
class
UserStateCache
(
object
):
class
UserStateCache
(
object
):
"""
"""
Cache for Scope.user_state xblock field data.
Cache for Scope.user_state xblock field data.
...
@@ -266,33 +296,6 @@ class FieldDataCache(object):
...
@@ -266,33 +296,6 @@ class FieldDataCache(object):
return
cache
return
cache
def
_all_usage_ids
(
self
,
descriptors
):
"""
Return a set of all usage_ids for the descriptors that this FieldDataCache is caching
against, and well as all asides for those descriptors.
"""
usage_ids
=
set
()
for
descriptor
in
descriptors
:
usage_ids
.
add
(
descriptor
.
scope_ids
.
usage_id
)
for
aside_type
in
self
.
asides
:
usage_ids
.
add
(
AsideUsageKeyV1
(
descriptor
.
scope_ids
.
usage_id
,
aside_type
))
return
usage_ids
def
_all_block_types
(
self
,
descriptors
):
"""
Return a set of all block_types that are cached by this FieldDataCache.
"""
block_types
=
set
()
for
descriptor
in
descriptors
:
block_types
.
add
(
BlockTypeKeyV1
(
descriptor
.
entry_point
,
descriptor
.
scope_ids
.
block_type
))
for
aside_type
in
self
.
asides
:
block_types
.
add
(
BlockTypeKeyV1
(
XBlockAside
.
entry_point
,
aside_type
))
return
block_types
def
_cache_fields
(
self
,
scope
,
fields
,
descriptors
):
def
_cache_fields
(
self
,
scope
,
fields
,
descriptors
):
"""
"""
Queries the database for all of the fields in the specified scope
Queries the database for all of the fields in the specified scope
...
@@ -301,19 +304,19 @@ class FieldDataCache(object):
...
@@ -301,19 +304,19 @@ class FieldDataCache(object):
cache
=
self
.
user_state_cache
=
UserStateCache
(
cache
=
self
.
user_state_cache
=
UserStateCache
(
self
.
user
,
self
.
user
,
self
.
course_id
,
self
.
course_id
,
self
.
_all_usage_ids
(
descriptor
s
),
_all_usage_keys
(
descriptors
,
self
.
aside
s
),
self
.
select_for_update
,
self
.
select_for_update
,
)
)
elif
scope
==
Scope
.
user_state_summary
:
elif
scope
==
Scope
.
user_state_summary
:
cache
=
self
.
user_state_summary_cache
=
UserStateSummaryCache
(
cache
=
self
.
user_state_summary_cache
=
UserStateSummaryCache
(
self
.
course_id
,
self
.
course_id
,
self
.
_all_usage_ids
(
descriptor
s
),
_all_usage_keys
(
descriptors
,
self
.
aside
s
),
self
.
select_for_update
,
self
.
select_for_update
,
)
)
elif
scope
==
Scope
.
preferences
:
elif
scope
==
Scope
.
preferences
:
cache
=
self
.
preferences_cache
=
PreferencesCache
(
cache
=
self
.
preferences_cache
=
PreferencesCache
(
self
.
user
,
self
.
user
,
self
.
_all_block_types
(
descriptor
s
),
_all_block_types
(
descriptors
,
self
.
aside
s
),
self
.
select_for_update
,
self
.
select_for_update
,
)
)
elif
scope
==
Scope
.
user_info
:
elif
scope
==
Scope
.
user_info
:
...
...
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