This repository has been archived by the owner on Aug 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
application.py
325 lines (275 loc) · 10.8 KB
/
application.py
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
from kanban_metrics import kanban
from pullrequest_metrics import pullRequest
from persistant_metrics import metrics
import config
import requests
'''---------------------------------------------------------------------------------------------------------User Interface start'''
def PorjectList_UI():
done = False
project_list = getProjectList()
while done == False:
counter = 0
print("Which Project do you want to see: ")
for pr in project_list:
print(str(counter)+" - "+pr["name"])
counter += 1
choice = input()
if int(choice) >= len(project_list):
print("option not avaible! please choose an available option")
else:
print("project id set",project_list[int(choice)]["id"])
project_id = project_list[int(choice)]["id"]
done = True
kanbanMetricMenu(project_id)
def menu():
print("Main menu")
print("----------------------------------")
print("Choose an option: ")
while True:
print("1- KanBan metrics: ")
print("2- Pull request metrics: ")
print("3- Persistant kanban metrics: ")
print("please enter your selection: ")
choice = input()
if choice == "1":
PorjectList_UI()
print("Main menu")
print("----------------------------------")
print("Choose an option: ")
elif choice == "2":
pullRequestMetricMennu()
print("Main menu")
print("----------------------------------")
print("Choose an option: ")
elif choice == "3":
persistantKanbanMetric_UI()
print("Main menu")
print("----------------------------------")
print("Choose an option: ")
else:
print("Option not avaible! please choose an available option")
def getProjectList():
r = requests.get(url=config.repo_base_url+"projects", headers=config.headers)
project_list = []
if r.status_code == 200:
project_list = r.json()
return project_list
def makeChoice(message):
done = False
while done == False:
print(message)
print("1- yes")
print("2- no")
choice = input()
if choice == "1":
return True
elif choice == "2":
return False
else:
print("wrong entry , please choose an available option")
def persistantKanbanMetric_UI():
done = False
while done == False:
print("Enter time intervals following the template (yyyy-mm-dd hh:mm)")
print("start date(yyyy-mm-dd hh:mm):")
startDate = input()
print("end date(yyyy-mm-dd hh:mm):")
endDate = input()
tasks = metrics.getData(startDate, endDate)
if len(tasks) > 0:
print("Metrics between "+startDate+" and "+endDate)
metrics.print_formatted_datase(tasks)
else:
print(" - no data")
done = not makeChoice(
"Do you wish you see the metrics between another time interval? ")
'''--------------------------------------------------------------------------------------------------------------------PR UI start'''
def pullRequestMetricMennu():
loop = True
print("Pull Request metrics")
print("----------------------------------")
while loop:
print("Choose an option: ")
print("1- lead time for a pull request: ")
print("2- average lead Time for closed pull request: ")
print("3- average pull request merge time: ")
print("4- Pull request merge rate: ")
print("5- Pull request rejection rate: ")
print("0- return to the main menu: ")
choice = input()
if choice == "1":
singlePRLeadTime_UI()
print("Pull Request metrics")
print("----------------------------------")
elif choice == "2":
avgClosedPRLeadTime_UI()
print(" ")
print("Pull Request metrics")
print("----------------------------------")
elif choice == "3":
avgMergePRLeadTime_UI()
print(" ")
print("Pull Request metrics")
print("----------------------------------")
elif choice == "4":
prMergeRate_UI()
print(" ")
print("Pull Request metrics")
print("----------------------------------")
elif choice == "5":
prRejectionRate_UI()
print(" ")
print("Pull Request metrics")
print("----------------------------------")
elif choice == "0":
loop = False
else:
print("Option not avaible! Please chose a valid option.")
def singlePRLeadTime_UI():
done = False
pr_list = pullRequest.getPullResquestList("all")
while done == False:
counter = 0
print("Which Pull Request's leadtime do you want to see: ")
for pr in pr_list:
print(str(counter)+" - "+pr["title"])
counter += 1
choice = input()
if int(choice) >= len(pr_list):
print("option not avaible! please choose an available option")
else:
leadTime = pullRequest.getSinglePullRequestLeadtime(
pr_list[int(choice)]["number"])
print(" - The leadtime for the pull request: " +
pr_list[int(choice)]["title"]+" is "+leadTime)
done = not makeChoice(
"Do you wish you see the lead time of another pull request? ")
def avgMergePRLeadTime_UI():
avg = pullRequest.averageMergeTimeClosedPR()
if avg != None:
print("the average merge time for merged Pull Request is "+str(avg)+" days")
def avgClosedPRLeadTime_UI():
avg = pullRequest.averageLeadTimeClosedPR()
if avg != None:
print("the average leadTime for closed Pull Request is "+str(avg)+" days")
def prRejectionRate_UI():
rate = pullRequest.prRejectionRate()
if rate != None:
print("Pull Request rejection rate is "+str(rate)+" %")
def prMergeRate_UI():
rate = pullRequest.prMergeRate()
if rate != None:
print("Pull Request merging rate is "+str(rate)+" %")
'''----------------------------------------------------------------------------------------------------------PR UI end'''
def kanbanMetricMenu(project_id):
loop = True
print("KanBan metrics")
print("----------------------------------")
while loop:
print("Choose an option: ")
print("1- lead Time for a task: ")
print("2- lead Time for closed tasks in a time interval: ")
print("3- view tasks in a specific column tasks: ")
print("4- list of completed tasks in a time interval: ")
print("0- return to the main menu: ")
choice = input()
if choice == "1":
singleTaskLeadTime_UI(project_id)
print("KanBan metrics")
print("----------------------------------")
elif choice == "2":
leadTimeForTasksInTimeInterval_UI(project_id)
print("KanBan metrics")
print("----------------------------------")
elif choice == "3":
taskInSpecificColumn_UI(project_id)
print("KanBan metrics")
print("----------------------------------")
elif choice == "4":
completedTasksInTimeInterval_UI(project_id)
print("KanBan metrics")
print("----------------------------------")
elif choice == "0":
menu()
else:
print("Option not avaible! Please chose a valid option.")
def singleTaskLeadTime_UI(project_id):
done = False
tasks_list = kanban.getKanBanTaskList(project_id)
while done == False:
counter = 0
print("Which task's leadtime do you want to see: ")
for task in tasks_list:
print(str(counter)+" - "+task["title"])
counter += 1
choice = input()
if int(choice) >= len(tasks_list):
print("option not avaible! please choose an available option")
else:
leadTime = kanban.getSingleTaskLeadtime(
tasks_list[int(choice)]["number"])
print(" - The leadtime for the task: " +
tasks_list[int(choice)]["title"]+" is "+leadTime)
done = not makeChoice(
"Do you wish you see the lead time of another task? ")
def taskInSpecificColumn_UI(project_id):
done = False
column_list = kanban.getKanBanColumnList(project_id)
while done == False:
counter = 0
print("Which column task do you want to see: ")
for column in column_list:
print(str(counter)+" - "+column["name"])
counter += 1
choice = input()
if int(choice) >= len(column_list):
print("option not avaible! please choose an available option")
else:
taskList = kanban.getActiveTasks(column_list[int(choice)]["id"])
print("list of active task in column: " +
column_list[int(choice)]["name"])
if len(taskList) > 0:
for task in taskList:
print(" - "+task["title"])
else:
print(" - no tasks at the moment")
done = not makeChoice(
"Do you wish you see the tasks of another column? ")
def leadTimeForTasksInTimeInterval_UI():
done = False
while done == False:
print("Enter time intervals following the template (yyyy-mm-dd)")
print("start date(yyyy-mm-dd):")
startDate = input()
print("end date(yyyy-mm-dd):")
endDate = input()
leadTimes = kanban.getMultiTaskleadtime(startDate, endDate)
if len(leadTimes) > 0:
for leadTime in leadTimes:
print(" - "+leadTime)
else:
print(" - no data at the moment")
done = not makeChoice(
"Do you wish you see the lead times between another time interval? ")
def completedTasksInTimeInterval_UI():
done = False
while done == False:
print("Enter time intervals following the template (yyyy-mm-dd)")
print("start date(yyyy-mm-dd):")
startDate = input()
print("end date(yyyy-mm-dd):")
endDate = input()
tasks = kanban.getCompletedTasks(startDate, endDate)
if len(tasks) > 0:
print("Task terminated between "+startDate+" and "+endDate)
for task in tasks:
print(" - "+task)
else:
print(" - no tasks")
done = not makeChoice(
"Do you wish you see the tasks terminated between another time interval? ")
'''---------------------------------------------------------------------------------------------------------User Interface end'''
def main():
menu()
if __name__ == "__main__":
main()