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
8dd87502
Commit
8dd87502
authored
9 years ago
by
Nathaniel Kofalt
Browse files
Options
Downloads
Patches
Plain Diff
Concise map fiddling as per
https://github.com/scitran/api/pull/128#discussion_r49914630
parent
e68b0baf
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
api/jobs.py
+5
-11
5 additions, 11 deletions
api/jobs.py
with
5 additions
and
11 deletions
api/jobs.py
+
5
−
11
View file @
8dd87502
...
...
@@ -220,21 +220,15 @@ class Jobs(base.RequestHandler):
def
stats
(
self
):
if
not
self
.
superuser_request
:
self
.
abort
(
403
,
'
Request requires superuser
'
)
# A simple count of jobs by state
result
=
config
.
db
.
jobs
.
aggregate
([{
"
$group
"
:
{
"
_id
"
:
"
$state
"
,
"
count
"
:
{
"
$sum
"
:
1
}}}])
# Map mongo result to a useful object
states
=
{}
# Don't randomly omit keys that are zero
for
s
in
JOB_STATES
:
states
[
s
]
=
0
for
r
in
result
:
key
=
r
[
'
_id
'
]
val
=
r
[
'
count
'
]
states
[
key
]
=
val
stats
=
{
s
:
0
for
s
in
JOB_STATES
}
stats
.
update
({
r
[
'
_id
'
]:
r
[
'
count
'
]
for
r
in
result
})
return
stat
e
s
return
stats
def
next
(
self
):
"""
...
...
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