ruz-bot/daemons/api.py
Administrator f7d181f144 fix stats
2022-10-22 13:25:20 +03:00

18 lines
656 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from flask import Flask
import settings
from helpers.mongo import mongo
def api():
app = Flask(__name__)
@app.route('/stats', methods=['GET'])
def stats():
text = f"Всего пользователей: {mongo.users_collection.count_documents({})}<br>" \
f"Подписано на уведомления: {mongo.users_collection.count_documents({'notify_minutes': {'$ne': None}})}<br>" \
f"Отправлено уведомлений за сегодня: {mongo.lessons_collection.count_documents({'notified': True})}"
return text
app.run(host="0.0.0.0", port=1238, debug=settings.DEBUG)