forked from aagirre92/A360_Bot_Analyzer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.py
93 lines (77 loc) · 2.09 KB
/
functions.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
def complexity_formula(row):
"""
This function is used for calculating the complexity of each task bot
:param row:
:return: Float
"""
COEF_LINES = 0.2
COEF_VARIABLES = 0.1
COEF_PACKAGES = 0.1
COEF_ERR = 0.1
COEF_LOOPS = 0.1
COEF_STEPS = 0.05
COEF_COMMENTS = 0.15
COEF_SCRIPTS = 0.15
COEF_EMAILS = 0.05
lines = row["Lines"]
variables = row["Variables"]
packages = row["Packages"]
if lines == 0:
x_lines = 0
elif 0 < lines < 100:
x_lines = lines / 100
else:
x_lines = 1
if variables == 0:
x_variables = 0
elif 0 < variables < 40:
x_variables = variables / 40
else:
x_variables = 1
if packages == 0:
x_packages = 0
elif 0 < packages < 30:
x_packages = packages / 30
else:
x_packages = 1
if row["Error Handling"]:
x_error_handling = COEF_ERR
else:
x_error_handling = 0
if row["Loops"] > 3:
x_loops = COEF_LOOPS
else:
x_loops = 0
if not row["Steps"]:
x_steps = COEF_STEPS
else:
x_steps = 0
if not row["Comments"]:
x_comments = COEF_COMMENTS
else:
x_comments = 0
if row["Scripts"]:
x_scripts = COEF_SCRIPTS
else:
x_scripts = 0
if row["Email send"]:
x_email_notifications = COEF_EMAILS
else:
x_email_notifications = 0
y = COEF_LINES * x_lines + COEF_VARIABLES * x_variables + COEF_PACKAGES * x_packages + x_error_handling + x_loops + x_steps + x_comments + x_scripts + x_email_notifications
return y
def process_complexity(df):
"""
Calculates process overall complexity, taking into consideration how many bots are involved
:param df: DataFrame
:return: Float
"""
complexity_max = df["Complexity Estimation"].max()
overall_complexity = 0
if len(df) > 10:
overall_complexity = complexity_max * 1.5
if overall_complexity > 1:
overall_complexity = 1
elif len(df) < 10:
overall_complexity = complexity_max
return overall_complexity