-
Notifications
You must be signed in to change notification settings - Fork 0
/
manage.py
32 lines (26 loc) · 806 Bytes
/
manage.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import datetime
from flask_script import Manager
from app import create_app, db
from app.models.todo import Todo
from app.models.user import User
from app.api_v1.webhook import send_message
from app.controllers.todo import list_todo_items
app = create_app()
manager = Manager(app)
@manager.command
def resetdb():
db.drop_all()
db.create_all()
# app.logger.debug(t)
@manager.command
def scheduled_reminder():
current_hour = datetime.datetime.now().hour
users = User.query.all()
for user in users:
if current_hour % user.reminder is 0:
if len(user.todos) > 0:
resp = list_todo_items(user.id)
send_message(user.id, resp)
# manager's doc = https://flask-script.readthedocs.io/en/latest/
if __name__ == "__main__":
manager.run()