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
3672c9a2
Commit
3672c9a2
authored
Aug 14, 2014
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make find_matching_* work during split bulk operations
parent
e7ce4106
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
48 additions
and
21 deletions
+48
-21
cms/djangoapps/contentstore/tests/test_crud.py
+3
-2
common/lib/xmodule/xmodule/modulestore/split_mongo/mongo_connection.py
+37
-13
common/lib/xmodule/xmodule/modulestore/split_mongo/split.py
+0
-0
common/lib/xmodule/xmodule/modulestore/split_mongo/split_draft.py
+4
-4
common/lib/xmodule/xmodule/modulestore/tests/test_split_modulestore_bulk_operations.py
+0
-0
lms/djangoapps/courseware/tests/test_module_render.py
+4
-2
No files found.
cms/djangoapps/contentstore/tests/test_crud.py
View file @
3672c9a2
...
@@ -205,9 +205,10 @@ class TemplateTests(unittest.TestCase):
...
@@ -205,9 +205,10 @@ class TemplateTests(unittest.TestCase):
data
=
"<problem></problem>"
data
=
"<problem></problem>"
)
)
# course root only updated 2x
# The draft course root has 2 revisions: the published revision, and then the subsequent
# changes to the draft revision
version_history
=
self
.
split_store
.
get_block_generations
(
test_course
.
location
)
version_history
=
self
.
split_store
.
get_block_generations
(
test_course
.
location
)
#
create course causes 2 versions for the time being; skip the first.
#
Base calculations on the draft revision, not the initial published revision
version_history
=
version_history
.
children
[
0
]
version_history
=
version_history
.
children
[
0
]
self
.
assertEqual
(
version_history
.
locator
.
version_guid
,
test_course
.
location
.
version_guid
)
self
.
assertEqual
(
version_history
.
locator
.
version_guid
,
test_course
.
location
.
version_guid
)
self
.
assertEqual
(
len
(
version_history
.
children
),
1
)
self
.
assertEqual
(
len
(
version_history
.
children
),
1
)
...
...
common/lib/xmodule/xmodule/modulestore/split_mongo/mongo_connection.py
View file @
3672c9a2
...
@@ -57,24 +57,36 @@ class MongoConnection(object):
...
@@ -57,24 +57,36 @@ class MongoConnection(object):
"""
"""
return
self
.
structures
.
find_one
({
'_id'
:
key
})
return
self
.
structures
.
find_one
({
'_id'
:
key
})
def
find_
matching_structures
(
self
,
query
):
def
find_
structures_by_id
(
self
,
ids
):
"""
"""
Find the structure matching the query. Right now the query must be a legal mongo query
Return all structures that specified in ``ids``.
:param query: a mongo-style query of {key: [value|{$in ..}|..], ..}
Arguments:
ids (list): A list of structure ids
"""
"""
return
self
.
structures
.
find
(
query
)
return
self
.
structures
.
find
(
{
'_id'
:
{
'$in'
:
ids
}}
)
def
insert_structure
(
self
,
structure
):
def
find_structures_derived_from
(
self
,
ids
):
"""
"""
Create the structure in the db
Return all structures that were immediately derived from a structure listed in ``ids``.
Arguments:
ids (list): A list of structure ids
"""
"""
self
.
structures
.
insert
(
structure
)
return
self
.
structures
.
find
({
'previous_version'
:
{
'$in'
:
ids
}}
)
def
update_structure
(
self
,
structure
):
def
find_ancestor_structures
(
self
,
original_version
,
block_id
):
"""
"""
Update the db record for structure
Find all structures that originated from ``original_version`` that contain ``block_id``.
Arguments:
original_version (str or ObjectID): The id of a structure
block_id (str): The id of the block in question
"""
"""
self
.
structures
.
update
({
'_id'
:
structure
[
'_id'
]},
structure
)
return
self
.
structures
.
find
({
'original_version'
:
original_version
,
'blocks.{}.edit_info.update_version'
.
format
(
block_id
):
{
'$exists'
:
True
}
})
def
upsert_structure
(
self
,
structure
):
def
upsert_structure
(
self
,
structure
):
"""
"""
...
@@ -94,11 +106,23 @@ class MongoConnection(object):
...
@@ -94,11 +106,23 @@ class MongoConnection(object):
])
])
)
)
def
find_matching_course_indexes
(
self
,
query
):
def
find_matching_course_indexes
(
self
,
branch
=
None
,
search_targets
=
None
):
"""
"""
Find the course_index matching the query. Right now the query must be a legal mongo query
Find the course_index matching particular conditions.
:param query: a mongo-style query of {key: [value|{$in ..}|..], ..}
Arguments:
branch: If specified, this branch must exist in the returned courses
search_targets: If specified, this must be a dictionary specifying field values
that must exist in the search_targets of the returned courses
"""
"""
query
=
son
.
SON
()
if
branch
is
not
None
:
query
[
'versions.{}'
.
format
(
branch
)]
=
{
'$exists'
:
True
}
if
search_targets
:
for
key
,
value
in
search_targets
.
iteritems
():
query
[
'search_targets.{}'
.
format
(
key
)]
=
value
return
self
.
course_index
.
find
(
query
)
return
self
.
course_index
.
find
(
query
)
def
insert_course_index
(
self
,
course_index
):
def
insert_course_index
(
self
,
course_index
):
...
...
common/lib/xmodule/xmodule/modulestore/split_mongo/split.py
View file @
3672c9a2
This diff is collapsed.
Click to expand it.
common/lib/xmodule/xmodule/modulestore/split_mongo/split_draft.py
View file @
3672c9a2
...
@@ -103,7 +103,7 @@ class DraftVersioningModuleStore(ModuleStoreDraftAndPublished, SplitMongoModuleS
...
@@ -103,7 +103,7 @@ class DraftVersioningModuleStore(ModuleStoreDraftAndPublished, SplitMongoModuleS
def
create_item
(
def
create_item
(
self
,
user_id
,
course_key
,
block_type
,
block_id
=
None
,
self
,
user_id
,
course_key
,
block_type
,
block_id
=
None
,
definition_locator
=
None
,
fields
=
None
,
definition_locator
=
None
,
fields
=
None
,
force
=
False
,
continue_version
=
False
,
skip_auto_publish
=
False
,
**
kwargs
force
=
False
,
skip_auto_publish
=
False
,
**
kwargs
):
):
"""
"""
See :py:meth `ModuleStoreDraftAndPublished.create_item`
See :py:meth `ModuleStoreDraftAndPublished.create_item`
...
@@ -113,7 +113,7 @@ class DraftVersioningModuleStore(ModuleStoreDraftAndPublished, SplitMongoModuleS
...
@@ -113,7 +113,7 @@ class DraftVersioningModuleStore(ModuleStoreDraftAndPublished, SplitMongoModuleS
item
=
super
(
DraftVersioningModuleStore
,
self
)
.
create_item
(
item
=
super
(
DraftVersioningModuleStore
,
self
)
.
create_item
(
user_id
,
course_key
,
block_type
,
block_id
=
block_id
,
user_id
,
course_key
,
block_type
,
block_id
=
block_id
,
definition_locator
=
definition_locator
,
fields
=
fields
,
definition_locator
=
definition_locator
,
fields
=
fields
,
force
=
force
,
continue_version
=
continue_version
,
**
kwargs
force
=
force
,
**
kwargs
)
)
if
not
skip_auto_publish
:
if
not
skip_auto_publish
:
self
.
_auto_publish_no_children
(
item
.
location
,
item
.
location
.
category
,
user_id
,
**
kwargs
)
self
.
_auto_publish_no_children
(
item
.
location
,
item
.
location
.
category
,
user_id
,
**
kwargs
)
...
@@ -121,13 +121,13 @@ class DraftVersioningModuleStore(ModuleStoreDraftAndPublished, SplitMongoModuleS
...
@@ -121,13 +121,13 @@ class DraftVersioningModuleStore(ModuleStoreDraftAndPublished, SplitMongoModuleS
def
create_child
(
def
create_child
(
self
,
user_id
,
parent_usage_key
,
block_type
,
block_id
=
None
,
self
,
user_id
,
parent_usage_key
,
block_type
,
block_id
=
None
,
fields
=
None
,
continue_version
=
False
,
**
kwargs
fields
=
None
,
**
kwargs
):
):
parent_usage_key
=
self
.
_map_revision_to_branch
(
parent_usage_key
)
parent_usage_key
=
self
.
_map_revision_to_branch
(
parent_usage_key
)
with
self
.
bulk_write_operations
(
parent_usage_key
.
course_key
):
with
self
.
bulk_write_operations
(
parent_usage_key
.
course_key
):
item
=
super
(
DraftVersioningModuleStore
,
self
)
.
create_child
(
item
=
super
(
DraftVersioningModuleStore
,
self
)
.
create_child
(
user_id
,
parent_usage_key
,
block_type
,
block_id
=
block_id
,
user_id
,
parent_usage_key
,
block_type
,
block_id
=
block_id
,
fields
=
fields
,
continue_version
=
continue_version
,
**
kwargs
fields
=
fields
,
**
kwargs
)
)
self
.
_auto_publish_no_children
(
parent_usage_key
,
item
.
location
.
category
,
user_id
,
**
kwargs
)
self
.
_auto_publish_no_children
(
parent_usage_key
,
item
.
location
.
category
,
user_id
,
**
kwargs
)
return
item
return
item
...
...
common/lib/xmodule/xmodule/modulestore/tests/test_split_modulestore_bulk_operations.py
View file @
3672c9a2
This diff is collapsed.
Click to expand it.
lms/djangoapps/courseware/tests/test_module_render.py
View file @
3672c9a2
...
@@ -332,7 +332,8 @@ class TestTOC(ModuleStoreTestCase):
...
@@ -332,7 +332,8 @@ class TestTOC(ModuleStoreTestCase):
self
.
toy_loc
,
self
.
request
.
user
,
self
.
toy_course
,
depth
=
2
)
self
.
toy_loc
,
self
.
request
.
user
,
self
.
toy_course
,
depth
=
2
)
@ddt.data
((
ModuleStoreEnum
.
Type
.
mongo
,
3
,
0
),
(
ModuleStoreEnum
.
Type
.
split
,
7
,
0
))
# TODO: LMS-11220: Document why split find count is 21
@ddt.data
((
ModuleStoreEnum
.
Type
.
mongo
,
3
,
0
),
(
ModuleStoreEnum
.
Type
.
split
,
21
,
0
))
@ddt.unpack
@ddt.unpack
def
test_toc_toy_from_chapter
(
self
,
default_ms
,
num_finds
,
num_sends
):
def
test_toc_toy_from_chapter
(
self
,
default_ms
,
num_finds
,
num_sends
):
with
self
.
store
.
default_store
(
default_ms
):
with
self
.
store
.
default_store
(
default_ms
):
...
@@ -359,7 +360,8 @@ class TestTOC(ModuleStoreTestCase):
...
@@ -359,7 +360,8 @@ class TestTOC(ModuleStoreTestCase):
for
toc_section
in
expected
:
for
toc_section
in
expected
:
self
.
assertIn
(
toc_section
,
actual
)
self
.
assertIn
(
toc_section
,
actual
)
@ddt.data
((
ModuleStoreEnum
.
Type
.
mongo
,
3
,
0
),
(
ModuleStoreEnum
.
Type
.
split
,
7
,
0
))
# TODO: LMS-11220: Document why split find count is 21
@ddt.data
((
ModuleStoreEnum
.
Type
.
mongo
,
3
,
0
),
(
ModuleStoreEnum
.
Type
.
split
,
21
,
0
))
@ddt.unpack
@ddt.unpack
def
test_toc_toy_from_section
(
self
,
default_ms
,
num_finds
,
num_sends
):
def
test_toc_toy_from_section
(
self
,
default_ms
,
num_finds
,
num_sends
):
with
self
.
store
.
default_store
(
default_ms
):
with
self
.
store
.
default_store
(
default_ms
):
...
...
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