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
7ab3bb21
Commit
7ab3bb21
authored
May 30, 2017
by
Adam
Committed by
GitHub
May 30, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #14869 from edx/adam/add-index-to-nodes
add indices to item nodes when dumping to neo4j
parents
fc57527c
43311329
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
3 deletions
+20
-3
openedx/core/djangoapps/coursegraph/management/commands/dump_to_neo4j.py
+3
-3
openedx/core/djangoapps/coursegraph/management/commands/tests/test_dump_to_neo4j.py
+17
-0
No files found.
openedx/core/djangoapps/coursegraph/management/commands/dump_to_neo4j.py
View file @
7ab3bb21
...
...
@@ -113,7 +113,6 @@ class ModuleStoreSerializer(object):
items
=
modulestore
()
.
get_items
(
course_id
)
# create nodes
nodes
=
[]
for
item
in
items
:
fields
,
block_type
=
self
.
serialize_item
(
item
)
...
...
@@ -121,19 +120,20 @@ class ModuleStoreSerializer(object):
fields
[
field_name
]
=
self
.
coerce_types
(
value
)
node
=
Node
(
block_type
,
'item'
,
**
fields
)
nodes
.
append
(
node
)
location_to_node
[
item
.
location
]
=
node
# create relationships
relationships
=
[]
for
item
in
items
:
for
child_loc
in
item
.
get_children
(
):
for
index
,
child_loc
in
enumerate
(
item
.
get_children
()
):
parent_node
=
location_to_node
.
get
(
item
.
location
)
child_node
=
location_to_node
.
get
(
child_loc
.
location
)
child_node
[
"index"
]
=
index
if
parent_node
is
not
None
and
child_node
is
not
None
:
relationship
=
Relationship
(
parent_node
,
"PARENT_OF"
,
child_node
)
relationships
.
append
(
relationship
)
nodes
=
location_to_node
.
values
()
return
nodes
,
relationships
@staticmethod
...
...
openedx/core/djangoapps/coursegraph/management/commands/tests/test_dump_to_neo4j.py
View file @
7ab3bb21
...
...
@@ -230,6 +230,23 @@ class TestModuleStoreSerializer(TestDumpToNeo4jCommandBase):
self
.
assertEqual
(
len
(
nodes
),
9
)
self
.
assertEqual
(
len
(
relationships
),
7
)
def
test_nodes_have_indices
(
self
):
"""
Test that we add index values on nodes
"""
nodes
,
relationships
=
self
.
mss
.
serialize_course
(
self
.
course
.
id
)
# the html node should have 0 index, and the problem should have 1
html_nodes
=
[
node
for
node
in
nodes
if
node
[
'block_type'
]
==
'html'
]
self
.
assertEqual
(
len
(
html_nodes
),
1
)
problem_nodes
=
[
node
for
node
in
nodes
if
node
[
'block_type'
]
==
'problem'
]
self
.
assertEqual
(
len
(
problem_nodes
),
1
)
html_node
=
html_nodes
[
0
]
problem_node
=
problem_nodes
[
0
]
self
.
assertEqual
(
html_node
[
'index'
],
0
)
self
.
assertEqual
(
problem_node
[
'index'
],
1
)
@ddt.data
(
(
1
,
1
),
(
object
,
"<type 'object'>"
),
...
...
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