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
37e0d00d
Commit
37e0d00d
authored
8 years ago
by
Megan Henning
Browse files
Options
Downloads
Patches
Plain Diff
Add endpoint to recalc all projects
parent
d5b2c718
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
api/api.py
+1
-0
1 addition, 0 deletions
api/api.py
api/dao/containerstorage.py
+22
-13
22 additions, 13 deletions
api/dao/containerstorage.py
api/handlers/containerhandler.py
+2
-2
2 additions, 2 deletions
api/handlers/containerhandler.py
with
25 additions
and
15 deletions
api/api.py
+
1
−
0
View file @
37e0d00d
...
...
@@ -172,6 +172,7 @@ routes = [
webapp2
.
Route
(
_format
(
r
'
/api/users/<uid:{user_id_re}>/<cont_name:{cont_name_re}>
'
),
containerhandler
.
ContainerHandler
,
name
=
'
user_conts
'
,
handler_method
=
'
get_all_for_user
'
,
methods
=
[
'
GET
'
]),
webapp2
.
Route
(
r
'
/api/projects/groups
'
,
containerhandler
.
ContainerHandler
,
handler_method
=
'
get_groups_with_project
'
,
methods
=
[
'
GET
'
]),
webapp2
.
Route
(
r
'
/api/projects/recalc
'
,
containerhandler
.
ContainerHandler
,
handler_method
=
'
calculate_project_compliance
'
,
methods
=
[
'
POST
'
]),
webapp2
.
Route
(
_format
(
r
'
/api/projects/<cid:{cid_re}>/template
'
),
containerhandler
.
ContainerHandler
,
handler_method
=
'
set_project_template
'
,
methods
=
[
'
POST
'
]),
webapp2
.
Route
(
_format
(
r
'
/api/projects/<cid:{cid_re}>/template/recalc
'
),
containerhandler
.
ContainerHandler
,
handler_method
=
'
calculate_project_compliance
'
,
methods
=
[
'
POST
'
]),
...
...
This diff is collapsed.
Click to expand it.
api/dao/containerstorage.py
+
22
−
13
View file @
37e0d00d
...
...
@@ -166,20 +166,29 @@ class ProjectStorage(ContainerStorage):
def
__init__
(
self
):
super
(
ProjectStorage
,
self
).
__init__
(
'
projects
'
,
use_object_id
=
True
)
def
recalc_sessions_compliance
(
self
,
project_id
):
project
=
self
.
get_container
(
project_id
,
get_children
=
True
)
if
not
project
:
raise
APINotFoundException
(
'
Could not find project {}
'
.
format
(
project_id
))
template
=
json
.
loads
(
project
.
get
(
'
template
'
,{}))
if
not
template
:
return
def
recalc_sessions_compliance
(
self
,
project_id
=
None
):
if
project_id
is
None
:
# Recalc all projects
projects
=
self
.
get_all_el
({
'
template
'
:
{
'
$exists
'
:
True
}},
None
,
None
)
else
:
changed_sessions
=
[]
session_storage
=
SessionStorage
()
for
s
in
project
.
get
(
'
sessions
'
,
[]):
changed
=
session_storage
.
recalc_session_compliance
(
s
[
'
_id
'
],
session
=
s
,
template
=
template
)
if
changed
:
changed_sessions
.
append
(
s
[
'
_id
'
])
project
=
self
.
get_container
(
project_id
,
get_children
=
True
)
if
project
:
projects
=
[
project
]
else
:
raise
APINotFoundException
(
'
Could not find project {}
'
.
format
(
project_id
))
changed_sessions
=
[]
for
project
in
projects
:
template
=
json
.
loads
(
project
.
get
(
'
template
'
,{}))
if
not
template
:
return
else
:
session_storage
=
SessionStorage
()
for
s
in
project
.
get
(
'
sessions
'
,
[]):
changed
=
session_storage
.
recalc_session_compliance
(
s
[
'
_id
'
],
session
=
s
,
template
=
template
)
if
changed
:
changed_sessions
.
append
(
s
[
'
_id
'
])
return
changed_sessions
class
SessionStorage
(
ContainerStorage
):
...
...
This diff is collapsed.
Click to expand it.
api/handlers/containerhandler.py
+
2
−
2
View file @
37e0d00d
...
...
@@ -509,10 +509,10 @@ class ContainerHandler(base.RequestHandler):
self
.
abort
(
404
,
'
Could not find project {}
'
.
format
(
project_id
))
def
calculate_project_compliance
(
self
,
**
kwargs
):
project_id
=
kwargs
.
pop
(
'
cid
'
)
project_id
=
kwargs
.
pop
(
'
cid
'
,
None
)
self
.
config
=
self
.
container_handler_configurations
[
'
projects
'
]
self
.
storage
=
self
.
config
[
'
storage
'
]
return
{
'
sessions_changed
'
:
self
.
storage
.
recalc_sess
s
ions_compliance
(
project_id
)}
return
{
'
sessions_changed
'
:
self
.
storage
.
recalc_sessions_compliance
(
project_id
=
project_id
)}
def
_get_validators
(
self
):
mongo_schema_uri
=
validators
.
schema_uri
(
'
mongo
'
,
self
.
config
.
get
(
'
storage_schema_file
'
))
...
...
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