Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Arkindex
Backend
Commits
f2e1e2e9
Verified
Commit
f2e1e2e9
authored
3 years ago
by
Erwan Rouchet
Browse files
Options
Downloads
Patches
Plain Diff
Remove unused ElementManager.get_descendings
parent
47b27803
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!1604
Remove unused ElementManager.get_descendings
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
arkindex/documents/managers.py
+0
-33
0 additions, 33 deletions
arkindex/documents/managers.py
arkindex/documents/tests/test_element_manager.py
+0
-7
0 additions, 7 deletions
arkindex/documents/tests/test_element_manager.py
with
0 additions
and
40 deletions
arkindex/documents/managers.py
+
0
−
33
View file @
f2e1e2e9
import
uuid
from
itertools
import
chain
import
django
...
...
@@ -127,38 +126,6 @@ class ElementManager(models.Manager):
"""
return
self
.
filter
(
paths__path__contains
=
[
parent_id
],
**
filters
).
order_by
(
'
paths__ordering
'
).
distinct
()
def
get_descendings
(
self
,
parents_ids
,
prefetch
=
(),
**
filters
):
"""
Get all child elements for some element IDs.
"""
assert
all
(
isinstance
(
x
,
uuid
.
UUID
)
for
x
in
parents_ids
),
'
UUIDs are required
'
# Loads paths and group them by element ids
# The map to str is needed to avoid a cast error in PG
from
arkindex.documents.models
import
ElementPath
paths
=
ElementPath
.
objects
.
filter
(
path__overlap
=
map
(
str
,
parents_ids
)).
order_by
(
'
element_id
'
,
'
ordering
'
)
tree
=
{
parent_id
:
[
p
.
element_id
for
p
in
paths
if
parent_id
in
p
.
path
]
for
parent_id
in
parents_ids
}
# Load children elements in bulk
children
=
self
.
filter
(
id__in
=
[
p
.
element_id
for
p
in
paths
],
**
filters
)
if
prefetch
:
children
=
children
.
prefetch_related
(
*
prefetch
)
return
{
parent_id
:
[
child
for
child
in
children
if
child
.
id
in
tree
.
get
(
parent_id
)
]
for
parent_id
in
parents_ids
}
def
get_neighbor_paths
(
self
,
element
,
n
=
1
):
"""
Get n neighbor paths: current, previous and next element paths
...
...
This diff is collapsed.
Click to expand it.
arkindex/documents/tests/test_element_manager.py
+
0
−
7
View file @
f2e1e2e9
...
...
@@ -38,13 +38,6 @@ class TestElementManager(FixtureTestCase):
ids
=
Element
.
objects
.
get_descending
(
self
.
p2
.
id
)
self
.
assertCountEqual
(
ids
,
[])
def
test_get_descendings
(
self
):
# Use all pages, expect Act and nothing else
ids
=
Element
.
objects
.
get_descendings
([
self
.
p1
.
id
,
self
.
p2
.
id
,
self
.
p3
.
id
])
self
.
assertCountEqual
(
ids
[
self
.
p1
.
id
],
[
self
.
act
])
self
.
assertCountEqual
(
ids
[
self
.
p2
.
id
],
[])
self
.
assertCountEqual
(
ids
[
self
.
p3
.
id
],
[])
def
test_get_neighbors
(
self
):
with
self
.
assertNumQueries
(
4
):
self
.
assertEqual
(
len
(
Element
.
objects
.
get_neighbors
(
self
.
p1
,
0
)),
1
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment