Skip to content

Commit 45c1e55

Browse files
Merge pull request #41 from devind-team/develop
refactor: change network load
2 parents d39ec5a + 7233981 commit 45c1e55

1 file changed

Lines changed: 16 additions & 14 deletions

File tree

services/network_load.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,26 @@
66
def interest_calculation() -> dict:
77
"""Генерация процента нагруженности сети."""
88
if datetime.today().month == 1 or 6 <= datetime.today().month <= 8:
9-
if 0 <= datetime.today().weekday() <= 4:
10-
return {
11-
'average_load': round(15 + uniform(0, 5), 2),
12-
'maximum_load': round(15 + uniform(5, 7), 2)
13-
}
14-
else:
9+
return week_day(average_load=15, maximum_load=42, start=0, average=5, end=10)
10+
else:
11+
return week_day(average_load=45, maximum_load=45, start=5, average=10, end=20)
12+
13+
14+
def week_day(average_load: int, maximum_load: int, start: int, average: int, end: int) -> dict:
15+
"""Вычисление нагрузки в зависимости от дня недели."""
16+
match datetime.today().weekday():
17+
case 5:
1518
return {
1619
'average_load': round(10 + uniform(0, 5), 2),
17-
'maximum_load': round(10 + uniform(5, 7), 2)
20+
'maximum_load': round(15 + uniform(5, 7), 2)
1821
}
19-
else:
20-
if 0 <= datetime.today().weekday() <= 4:
22+
case 6:
2123
return {
22-
'average_load': round(45 + uniform(5, 10), 2),
23-
'maximum_load': round(45 + uniform(10, 20), 2)
24+
'average_load': round(5 + uniform(0, 5), 2),
25+
'maximum_load': round(5 + uniform(5, 7), 2)
2426
}
25-
else:
27+
case _:
2628
return {
27-
'average_load': round(42 + uniform(0, 5), 2),
28-
'maximum_load': round(42 + uniform(5, 10), 2)
29+
'average_load': round(average_load + uniform(start, average), 2),
30+
'maximum_load': round(maximum_load + uniform(average, end), 2)
2931
}

0 commit comments

Comments
 (0)