Update docker-compose to include voice_users volume, modify Grafana dashboard expressions for active and total users, and adjust message sender status check interval to every 4 hours.

This commit is contained in:
2025-09-03 22:08:07 +03:00
parent ec62183e2a
commit 18d6f3d441
3 changed files with 8 additions and 7 deletions

View File

@@ -115,6 +115,7 @@ services:
volumes: volumes:
- ./bots/telegram-helper-bot/database:/app/database:rw - ./bots/telegram-helper-bot/database:/app/database:rw
- ./bots/telegram-helper-bot/logs:/app/logs:rw - ./bots/telegram-helper-bot/logs:/app/logs:rw
- ./bots/telegram-helper-bot/voice_users:/app/voice_users:rw
- ./bots/telegram-helper-bot/.env:/app/.env:ro - ./bots/telegram-helper-bot/.env:/app/.env:ro
networks: networks:
- bots_network - bots_network

View File

@@ -450,7 +450,7 @@
"type": "prometheus", "type": "prometheus",
"uid": "PBFA97CFB590B2093" "uid": "PBFA97CFB590B2093"
}, },
"expr": "sum(active_users)", "expr": "active_users{user_type=\"daily\"}",
"refId": "A" "refId": "A"
} }
], ],
@@ -537,7 +537,7 @@
"type": "prometheus", "type": "prometheus",
"uid": "PBFA97CFB590B2093" "uid": "PBFA97CFB590B2093"
}, },
"expr": "active_users{user_type=\"total\"}", "expr": "total_users",
"refId": "A" "refId": "A"
} }
], ],

View File

@@ -60,15 +60,15 @@ class MessageSender:
return False return False
def should_send_status(self) -> bool: def should_send_status(self) -> bool:
"""Проверка, нужно ли отправить статус (каждые 30 минут в 00 и 30 минут часа)""" """Проверка, нужно ли отправить статус (каждые 4 часа в 00 минут)"""
now = datetime.now() now = datetime.now()
# Проверяем, что сейчас 00 или 30 минут часа # Проверяем, что сейчас 00 минут часа и час кратен 4 (0, 4, 8, 12, 16, 20)
if now.minute in [0, 30]: if now.minute == 0 and now.hour % 4 == 0:
# Проверяем, не отправляли ли мы уже статус в эту минуту # Проверяем, не отправляли ли мы уже статус в этот час
if (self.last_status_time is None or if (self.last_status_time is None or
self.last_status_time.hour != now.hour or self.last_status_time.hour != now.hour or
self.last_status_time.minute != now.minute): self.last_status_time.day != now.day):
self.last_status_time = now self.last_status_time = now
return True return True