api
This commit is contained in:
parent
4b59a7bf98
commit
5b76f3528c
@ -47,3 +47,24 @@ services:
|
|||||||
update_config:
|
update_config:
|
||||||
parallelism: 1
|
parallelism: 1
|
||||||
order: start-first
|
order: start-first
|
||||||
|
|
||||||
|
api:
|
||||||
|
image: mathwave/sprint-repo:ruz-bot
|
||||||
|
networks:
|
||||||
|
- common-infra-nginx
|
||||||
|
environment:
|
||||||
|
MONGO_HOST: "mongo.develop.sprinthub.ru"
|
||||||
|
MONGO_PASSWORD: $MONGO_PASSWORD_DEV
|
||||||
|
TELEGRAM_TOKEN: $TELEGRAM_TOKEN_DEV
|
||||||
|
command: api
|
||||||
|
deploy:
|
||||||
|
mode: replicated
|
||||||
|
restart_policy:
|
||||||
|
condition: any
|
||||||
|
update_config:
|
||||||
|
parallelism: 1
|
||||||
|
order: start-first
|
||||||
|
|
||||||
|
networks:
|
||||||
|
common-infra-nginx:
|
||||||
|
external: true
|
||||||
|
18
daemons/api.py
Normal file
18
daemons/api.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
from flask import Flask
|
||||||
|
|
||||||
|
import settings
|
||||||
|
from helpers.mongo import mongo
|
||||||
|
|
||||||
|
|
||||||
|
def api():
|
||||||
|
app = Flask(__name__)
|
||||||
|
|
||||||
|
@app.route('/stats', methods=['GET'])
|
||||||
|
def stats():
|
||||||
|
return {
|
||||||
|
"Всего пользователей": mongo.users_collection.count_documents({}),
|
||||||
|
"Подписано на уведомления": mongo.users_collection.count_documents({"notify_minutes": {"$ne": None}}),
|
||||||
|
"Отправлено уведомлений за сегодня": mongo.lessons_collection.count_documents({"notified": True})
|
||||||
|
}
|
||||||
|
|
||||||
|
app.run(host="0.0.0.0", port=1238, debug=settings.DEBUG)
|
@ -1,5 +1,6 @@
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
from daemons.api import api
|
||||||
from daemons.bot import bot
|
from daemons.bot import bot
|
||||||
from daemons.fetch import fetch
|
from daemons.fetch import fetch
|
||||||
from daemons.notify import notify
|
from daemons.notify import notify
|
||||||
@ -15,5 +16,8 @@ elif arg == "fetch":
|
|||||||
elif arg == "notify":
|
elif arg == "notify":
|
||||||
print("notify is starting")
|
print("notify is starting")
|
||||||
notify()
|
notify()
|
||||||
|
elif arg == "api":
|
||||||
|
print("api is starting")
|
||||||
|
api()
|
||||||
else:
|
else:
|
||||||
raise ValueError(f"Unknown param {arg}")
|
raise ValueError(f"Unknown param {arg}")
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
certifi==2022.9.24
|
certifi==2022.9.24
|
||||||
charset-normalizer==2.1.1
|
charset-normalizer==2.1.1
|
||||||
|
click==8.1.3
|
||||||
|
Flask==2.2.2
|
||||||
idna==3.4
|
idna==3.4
|
||||||
|
itsdangerous==2.1.2
|
||||||
|
Jinja2==3.1.2
|
||||||
|
MarkupSafe==2.1.1
|
||||||
marshmallow==3.18.0
|
marshmallow==3.18.0
|
||||||
marshmallow-dataclass==8.5.9
|
marshmallow-dataclass==8.5.9
|
||||||
mypy-extensions==0.4.3
|
mypy-extensions==0.4.3
|
||||||
@ -15,3 +20,4 @@ six==1.16.0
|
|||||||
typing-inspect==0.8.0
|
typing-inspect==0.8.0
|
||||||
typing_extensions==4.4.0
|
typing_extensions==4.4.0
|
||||||
urllib3==1.26.12
|
urllib3==1.26.12
|
||||||
|
Werkzeug==2.2.2
|
||||||
|
Loading…
Reference in New Issue
Block a user