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
aa6ad67f
Commit
aa6ad67f
authored
8 years ago
by
Megan Henning
Browse files
Options
Downloads
Patches
Plain Diff
Add Project Report
parent
338d9fa6
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
api/handlers/reporthandler.py
+28
-6
28 additions, 6 deletions
api/handlers/reporthandler.py
with
28 additions
and
6 deletions
api/handlers/reporthandler.py
+
28
−
6
View file @
aa6ad67f
import
json
import
bson
from
..
import
base
from
..
import
config
...
...
@@ -23,13 +24,13 @@ class ReportHandler(base.RequestHandler):
report
=
SiteReport
()
elif
report_type
==
'
project
'
:
project_list
=
kwargs
.
get
(
'
projects
'
,
[]
)
project_list
=
self
.
request
.
GET
.
get
all
(
'
projects
'
)
if
len
(
project_list
)
<
1
:
self
.
abort
(
400
,
'
List of projects requried for Project Report
'
)
report
=
ProjectReport
(
kwargs
.
get
(
'
project
s
'
)
,
start_date
=
kwargs
.
get
(
'
start_date
'
),
end_date
=
kwargs
.
get
(
'
end
_date
'
))
report
=
ProjectReport
(
project
_list
,
start_date
=
self
.
get_param
(
'
start_date
'
),
end_date
=
self
.
get_param
(
'
start
_date
'
))
else
:
# They should never even get this far because of filtering in api.py
...
...
@@ -72,7 +73,7 @@ class SiteReport(Report):
for
g
in
groups
:
group
=
{}
group
[
'
name
'
]
=
g
.
get
(
'
name
'
,
''
)
group
[
'
name
'
]
=
g
.
get
(
'
name
'
)
project_ids
=
[
p
[
'
_id
'
]
for
p
in
config
.
db
.
projects
.
find
({
'
group
'
:
group
[
'
name
'
]},
[])]
group
[
'
project_count
'
]
=
len
(
project_ids
)
...
...
@@ -107,4 +108,25 @@ class ProjectReport(Report):
self
.
end_date
=
end_date
def
build
(
self
):
return
{}
report
=
{}
report
[
'
projects
'
]
=
[]
projects
=
config
.
db
.
projects
.
find
({
'
_id
'
:
{
'
$in
'
:
map
(
bson
.
ObjectId
,
self
.
projects
)}})
for
p
in
projects
:
project
=
{}
project
[
'
name
'
]
=
p
.
get
(
'
label
'
)
project
[
'
group_name
'
]
=
p
.
get
(
'
group
'
)
admins
=
[]
for
perm
in
p
.
get
(
'
permissions
'
,
[]):
if
perm
.
get
(
'
access
'
)
==
'
admin
'
:
admins
.
append
(
perm
.
get
(
'
_id
'
))
admin_objs
=
config
.
db
.
users
.
find
({
'
_id
'
:
{
'
$in
'
:
admins
}})
# This could also be a mongo project aggregation
project
[
'
admins
'
]
=
map
(
lambda
x
:
x
.
get
(
'
firstname
'
,
''
)
+
'
'
+
x
.
get
(
'
lastname
'
,
''
),
admin_objs
)
project
[
'
session_count
'
]
=
config
.
db
.
sessions
.
count
({
'
project
'
:
p
[
'
_id
'
]})
report
[
'
projects
'
].
append
(
project
)
return
report
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