Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
IDATT2900-072
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mattias Agentoft Eggen
IDATT2900-072
Commits
465691a8
Commit
465691a8
authored
3 years ago
by
Mattias Eggen
Browse files
Options
Downloads
Patches
Plain Diff
Added session for speed improvement
parent
91745325
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bbcli/endpoints.py
+13
-6
13 additions, 6 deletions
bbcli/endpoints.py
with
13 additions
and
6 deletions
bbcli/endpoints.py
+
13
−
6
View file @
465691a8
from
concurrent.futures
import
ThreadPoolExecutor
import
time
from
venv
import
create
import
requests
import
bbcli.cli
as
cli
...
...
@@ -83,7 +85,7 @@ def get_course_contents(course_id: str):
click
.
echo
(
map
)
def
get_children
(
worklist
,
url
,
acc
,
count
:
int
=
0
):
def
get_children
(
session
,
worklist
,
url
,
acc
,
count
:
int
=
0
):
count
=
count
+
1
key
=
'
hasChildren
'
if
len
(
worklist
)
==
0
:
...
...
@@ -92,7 +94,7 @@ def get_children(worklist, url, acc, count: int = 0):
node
=
worklist
.
pop
()
id
=
node
.
data
[
'
id
'
]
old
=
f
'
{
url
}
/
{
id
}
/children
'
response
=
requests
.
get
(
old
,
cookies
=
cli
.
cookies
)
response
=
session
.
get
(
old
,
cookies
=
cli
.
cookies
)
if
check_response
(
response
)
==
False
:
return
acc
else
:
...
...
@@ -106,7 +108,7 @@ def get_children(worklist, url, acc, count: int = 0):
else
:
child
=
Node
(
children
[
i
],
False
,
node
)
acc
.
append
(
child
)
return
get_children
(
worklist
,
url
,
acc
)
return
get_children
(
session
,
worklist
,
url
,
acc
)
def
create_tree
(
root
,
nodes
):
...
...
@@ -145,8 +147,10 @@ def get_assignments(course_id: str):
'''
Get the assignments
'''
session
=
requests
.
Session
()
url
=
f
'
{
base_url
}
courses/
{
course_id
}
/contents
'
response
=
requests
.
get
(
url
,
cookies
=
cli
.
cookies
)
start
=
time
.
time
()
response
=
session
.
get
(
url
,
cookies
=
cli
.
cookies
)
if
check_response
(
response
)
==
False
:
return
else
:
...
...
@@ -154,5 +158,8 @@ def get_assignments(course_id: str):
for
root
in
data
:
root
=
Node
(
root
,
True
)
worklist
=
[
root
]
res
=
get_children
(
worklist
,
url
,
[])
create_tree
(
root
,
res
)
\ No newline at end of file
res
=
get_children
(
session
,
worklist
,
url
,
[])
create_tree
(
root
,
res
)
end
=
time
.
time
()
print
(
f
'
\n
download time:
{
end
-
start
}
seconds
'
)
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