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

View file

@ -2,3 +2,6 @@ cron:
- description: update project data - description: update project data
url: /api/projects/updateProjectsInfo 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