ruz-bot/daemons/api.py
2022-10-25 19:12:32 +03:00

21 lines
1.1 KiB
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({'hse_id': {'$ne': None}})}" \
f"Подписано на уведомления: {mongo.users_collection.count_documents({'notify_minutes': {'$ne': None}})}<br>" \
f"Отписались от уведомлений: {mongo.users_collection.count_documents({'notify_minutes': None})}" \
f"Отправлено уведомлений за сегодня: {mongo.lessons_collection.count_documents({'notified': True})}" \
f"Проиндексировано занятий из РУЗа: {mongo.lessons_collection.count_documents({})}"
return text
app.run(host="0.0.0.0", port=1238, debug=settings.DEBUG)