-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathgitlab_todos_total
executable file
·47 lines (40 loc) · 1.3 KB
/
gitlab_todos_total
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env python
from lib import get_gitlab_instance
import sys
labels = {
'issue': 'Issue',
'milestone': 'Milestone',
'merge_request': 'MergeRequest',
'note': 'Note',
'project': 'Project',
'snippet': 'Snippet',
'user': 'User'
}
if len(sys.argv) >= 2 and sys.argv[1] == 'config':
print('graph_title GitLab open ToDo items')
print('graph_vlabel ToDo items')
print('graph_args -l 0')
print('graph_category gitlab')
print('issue.label Issues')
print('issue.draw AREA')
print('milestone.label Milestones')
print('milestone.draw STACK')
print('merge_request.label Merge Requests')
print('merge_request.draw STACK')
print('note.label Notes')
print('note.draw STACK')
print('project.label Projects')
print('project.draw STACK')
print('snippet.label Snippets')
print('snippet.draw STACK')
print('user.label Users')
print('user.draw STACK')
sys.exit(0)
gitlab = get_gitlab_instance()
db = gitlab.get_db_connection()
for label in labels:
cursor = db.cursor()
cursor.execute("SELECT COUNT(*) AS count FROM todos WHERE state = 'pending' AND target_type = %(target_type)s", {'target_type': labels[label]})
print('{label}.value {value}'.format(label=label, value=cursor.fetchone()[0]))
cursor.close()
db.close()