added crone jobs

This commit is contained in:
Aran Zaiger 2015-08-02 17:42:49 +03:00
parent 9a17e14201
commit cc8e07bc17
2 changed files with 27 additions and 23 deletions

View file

@ -25,6 +25,7 @@ from models.Project import Project
#Validation Utils Libs
from SE_API.Validation_Utils import *
from SE_API.Respones_Utils import *
from Email_Utils import *
task_routes = Blueprint("task_routes", __name__)
@ -871,30 +872,30 @@ def sendTaskReminder():
tasks = Task.all()
#go over all the courses
for t in tasks.run():
if t.dueDate == datetime.date.today() + datetime.timedelta(days=1):
course = Course.get_by_id(int(t.courseId))
if t.isPersonal:
for uId in course.membersId:
tc = TaskComponent.all().filter("taskId = ", t.key().id()).filter("userId = ", int(uId))
if tc.count() == 0:
#SEND MAIL!! TODO
print ""
try:
for t in tasks.run():
if t.dueDate == datetime.date.today() + datetime.timedelta(days=1):
course = Course.get_by_id(int(t.courseId))
if t.isPersonal:
for uId in course.membersId:
tc = TaskComponent.all().filter("taskId = ", t.key().id()).filter("userId = ", int(uId))
if tc.count() == 0:
user = User.get_by_id(int(uId))
send_task_reminder(user.email, user.name, t.title, course.courseName)
print ""
else:
projects = Project.all().filter("courseId = ", course.key().id())
for p in projects:
tc = TaskComponent.all().filter("taskId = ", t.key().id()).filter("userId = ", p.key().id())
if tc.count() == 0:
#SEND MAIL!! TODO
print ""
else:
projects = Project.all().filter("courseId = ", course.key().id())
for p in projects.run():
tc = TaskComponent.all().filter("taskId = ", t.key().id()).filter("userId = ", p.key().id())
if tc.count() == 0:
for uId in p.membersId:
user = User.get_by_id(int(uId))
send_task_reminder(user.email, user.name, t.title, course.courseName)
return accepted()
#go over all
return accepted("Task deleted")
except:
return bad_request()

View file

@ -1,4 +1,7 @@
cron:
- description: update project data
url: /api/projects/updateProjectsInfo
schedule: every 1 hours
schedule: every 1 hours
- description: send task notification mail
url: /api/tasks/sendTaskReminder
schedule: every day 03:00