Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to JiHu GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Chenhao Ma
core
Commits
fc86fa33
Commit
fc86fa33
authored
7 years ago
by
Harsha Kethineni
Browse files
Options
Downloads
Patches
Plain Diff
Request body is now list of nodes
parent
7361cb94
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
api/download.py
+54
-34
54 additions, 34 deletions
api/download.py
test/integration_tests/python/test_download.py
+6
-6
6 additions, 6 deletions
test/integration_tests/python/test_download.py
with
60 additions
and
40 deletions
api/download.py
+
54
−
34
View file @
fc86fa33
...
...
@@ -318,42 +318,62 @@ class Download(base.RequestHandler):
def
summary
(
self
):
"""
Return a summary of what has been/will be downloaded based on a given query
"""
res
=
{}
req
=
self
.
request
.
json_body
req
[
'
_id
'
]
=
bson
.
ObjectId
(
req
[
'
_id
'
])
level
=
req
[
'
level
'
]
containers
=
[
'
projects
'
,
'
sessions
'
,
'
acquisitions
'
]
cont_query
=
{}
if
level
==
'
projects
'
:
# Grab sessions and their ids
sessions
=
config
.
db
.
sessions
.
find
({
'
project
'
:
req
[
'
_id
'
]},
{
'
_id
'
:
1
})
session_ids
=
[
s
[
'
_id
'
]
for
s
in
sessions
]
# for each type of container below it will have a slightly modified match query
cont_query
=
{
'
projects
'
:
{
'
_id
'
:
req
[
'
_id
'
]},
'
sessions
'
:
{
'
project
'
:
req
[
'
_id
'
]},
'
acquisitions
'
:
{
'
session
'
:
{
'
$in
'
:
session_ids
}}
}
elif
level
==
'
sessions
'
:
# for each type of container below it will have a slightly modified match query
cont_query
=
{
'
sessions
'
:
{
'
_id
'
:
req
[
'
_id
'
]},
'
acquisitions
'
:
{
'
session
'
:
req
[
'
_id
'
]}
}
containers
=
containers
[
1
:]
elif
level
==
'
acquisitions
'
:
cont_query
[
'
acquisitions
'
]
=
{
'
_id
'
:
req
[
'
_id
'
]}
containers
=
containers
[
-
1
:]
elif
level
==
'
analyses
'
:
cont_query
[
'
analyses
'
]
=
{
'
_id
'
:
req
[
'
_id
'
]}
containers
=
[
'
analyses
'
]
else
:
self
.
abort
(
400
,
"
{} not a recognized level
"
.
format
(
level
))
cont_query
=
{
'
projects
'
:
{
'
_id
'
:
{
'
$in
'
:[]}},
'
sessions
'
:
{
'
_id
'
:
{
'
$in
'
:[]}},
'
acquisitions
'
:
{
'
_id
'
:
{
'
$in
'
:[]}},
'
analyses
'
:
{
'
_id
'
:
{
'
$in
'
:[]}}
}
for
node
in
req
:
node
[
'
_id
'
]
=
bson
.
ObjectId
(
node
[
'
_id
'
])
level
=
node
[
'
level
'
]
containers
=
{
'
projects
'
:
0
,
'
sessions
'
:
0
,
'
acquisitions
'
:
0
,
'
analyses
'
:
0
}
if
level
==
'
project
'
:
# Grab sessions and their ids
sessions
=
config
.
db
.
sessions
.
find
({
'
project
'
:
node
[
'
_id
'
]},
{
'
_id
'
:
1
})
session_ids
=
[
s
[
'
_id
'
]
for
s
in
sessions
]
acquisitions
=
config
.
db
.
acquisitions
.
find
({
'
session
'
:
{
'
$in
'
:
session_ids
}},
{
'
_id
'
:
1
})
acquisition_ids
=
[
a
[
'
_id
'
]
for
a
in
acquisitions
]
containers
[
'
projects
'
]
=
1
containers
[
'
sessions
'
]
=
1
containers
[
'
acquisitions
'
]
=
1
# for each type of container below it will have a slightly modified match query
cont_query
.
get
(
'
projects
'
,{}).
get
(
'
_id
'
,{}).
get
(
'
$in
'
).
append
(
node
[
'
_id
'
])
cont_query
[
'
sessions
'
][
'
_id
'
][
'
$in
'
]
=
cont_query
[
'
sessions
'
][
'
_id
'
][
'
$in
'
]
+
session_ids
cont_query
[
'
acquisitions
'
][
'
_id
'
][
'
$in
'
]
=
cont_query
[
'
acquisitions
'
][
'
_id
'
][
'
$in
'
]
+
acquisition_ids
elif
level
==
'
session
'
:
acquisitions
=
config
.
db
.
acquisitions
.
find
({
'
session
'
:
node
[
'
_id
'
]},
{
'
_id
'
:
1
})
acquisition_ids
=
[
a
[
'
_id
'
]
for
a
in
acquisitions
]
# for each type of container below it will have a slightly modified match query
cont_query
.
get
(
'
sessions
'
,{}).
get
(
'
_id
'
,{}).
get
(
'
$in
'
).
append
(
node
[
'
_id
'
])
cont_query
[
'
acquisitions
'
][
'
_id
'
][
'
$in
'
]
=
cont_query
[
'
acquisitions
'
][
'
_id
'
][
'
$in
'
]
+
acquisition_ids
containers
[
'
sessions
'
]
=
1
containers
[
'
acquisitions
'
]
=
1
elif
level
==
'
acquisition
'
:
cont_query
.
get
(
'
acquisitions
'
,{}).
get
(
'
_id
'
,{}).
get
(
'
$in
'
).
append
(
node
[
'
_id
'
])
containers
[
'
acquisitions
'
]
=
1
elif
level
==
'
analysis
'
:
cont_query
.
get
(
'
analyses
'
,{}).
get
(
'
_id
'
,{}).
get
(
'
$in
'
).
append
(
node
[
'
_id
'
])
containers
[
'
analyses
'
]
=
1
else
:
self
.
abort
(
400
,
"
{} not a recognized level
"
.
format
(
level
))
containers
=
[
cont
for
cont
in
containers
if
containers
[
cont
]
==
1
]
res
=
{}
for
cont_name
in
containers
:
# Aggregate file types
pipeline
=
[
...
...
This diff is collapsed.
Click to expand it.
test/integration_tests/python/test_download.py
+
6
−
6
View file @
fc86fa33
...
...
@@ -425,22 +425,22 @@ def test_summary(data_builder, as_admin, file_form):
missing_object_id
=
'
000000000000000000000000
'
r
=
as_admin
.
post
(
'
/download/summary
'
,
json
=
{
"
level
"
:
"
project
s
"
,
"
_id
"
:
project
})
r
=
as_admin
.
post
(
'
/download/summary
'
,
json
=
[
{
"
level
"
:
"
project
"
,
"
_id
"
:
project
}
]
)
assert
r
.
ok
assert
len
(
r
.
json
())
==
1
assert
r
.
json
().
get
(
"
csv
"
,
{}).
get
(
"
count
"
,
0
)
==
4
r
=
as_admin
.
post
(
'
/download/summary
'
,
json
=
{
"
level
"
:
"
session
s
"
,
"
_id
"
:
session
})
r
=
as_admin
.
post
(
'
/download/summary
'
,
json
=
[
{
"
level
"
:
"
session
"
,
"
_id
"
:
session
}
]
)
assert
r
.
ok
assert
len
(
r
.
json
())
==
1
assert
r
.
json
().
get
(
"
csv
"
,
{}).
get
(
"
count
"
,
0
)
==
2
r
=
as_admin
.
post
(
'
/download/summary
'
,
json
=
{
"
level
"
:
"
acquisition
s
"
,
"
_id
"
:
acquisition
}
)
r
=
as_admin
.
post
(
'
/download/summary
'
,
json
=
[
{
"
level
"
:
"
acquisition
"
,
"
_id
"
:
acquisition
},{
"
level
"
:
"
acquisition
"
,
"
_id
"
:
acquisition
2
}]
)
assert
r
.
ok
assert
len
(
r
.
json
())
==
1
assert
r
.
json
().
get
(
"
csv
"
,
{}).
get
(
"
count
"
,
0
)
==
1
assert
r
.
json
().
get
(
"
csv
"
,
{}).
get
(
"
count
"
,
0
)
==
2
r
=
as_admin
.
post
(
'
/download/summary
'
,
json
=
{
"
level
"
:
"
group
s
"
,
"
_id
"
:
missing_object_id
})
r
=
as_admin
.
post
(
'
/download/summary
'
,
json
=
[
{
"
level
"
:
"
group
"
,
"
_id
"
:
missing_object_id
}
]
)
assert
r
.
status_code
==
400
r
=
as_admin
.
post
(
'
/sessions/
'
+
session
+
'
/analyses
'
,
files
=
file_form
(
...
...
@@ -448,7 +448,7 @@ def test_summary(data_builder, as_admin, file_form):
assert
r
.
ok
analysis
=
r
.
json
()[
'
_id
'
]
r
=
as_admin
.
post
(
'
/download/summary
'
,
json
=
{
"
level
"
:
"
analys
e
s
"
,
"
_id
"
:
analysis
})
r
=
as_admin
.
post
(
'
/download/summary
'
,
json
=
[
{
"
level
"
:
"
analys
i
s
"
,
"
_id
"
:
analysis
}
]
)
assert
r
.
ok
assert
len
(
r
.
json
())
==
1
assert
r
.
json
().
get
(
"
tabular data
"
,
{}).
get
(
"
count
"
,
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