Skip to content

Commit 43c3fb6

Browse files
refactor: change network load
1 parent 00c797b commit 43c3fb6

2 files changed

Lines changed: 22 additions & 11 deletions

File tree

services/network_load.py

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,25 @@
55

66
def interest_calculation() -> dict:
77
"""Генерация процента нагруженности сети."""
8-
week_day = datetime.today().weekday()
9-
if 0 <= week_day <= 4:
10-
return {
11-
'average_load': round(45 + uniform(5, 10), 2),
12-
'maximum_load': round(45 + uniform(10, 20), 2)
13-
}
8+
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:
15+
return {
16+
'average_load': round(10 + uniform(0, 5), 2),
17+
'maximum_load': round(10 + uniform(5, 7), 2)
18+
}
1419
else:
15-
return {
16-
'average_load': round(42 + uniform(0, 5), 2),
17-
'maximum_load': round(42 + uniform(5, 10), 2)
18-
}
20+
if 0 <= datetime.today().weekday() <= 4:
21+
return {
22+
'average_load': round(45 + uniform(5, 10), 2),
23+
'maximum_load': round(45 + uniform(10, 20), 2)
24+
}
25+
else:
26+
return {
27+
'average_load': round(42 + uniform(0, 5), 2),
28+
'maximum_load': round(42 + uniform(5, 10), 2)
29+
}

task.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ async def send_message() -> None:
4545

4646

4747
schedule.every().day.at(f'{NOTIFICATION_SEND_TIME}').do(send_message)
48-
# schedule.every(20).seconds.do(send_message) # noqa
48+
# schedule.every(10).seconds.do(send_message) # noqa
4949

5050
while True:
5151
get_event_loop().run_until_complete(schedule.run_pending())

0 commit comments

Comments
 (0)