Example #1
0
def auto_unlock_tasks():
    with application.app_context():
        # Identify distinct project IDs that were touched in the last 2 hours
        query = (TaskHistory.query.with_entities(
            TaskHistory.project_id
        ).filter(
            func.DATE(TaskHistory.action_date) > datetime.datetime.utcnow() -
            datetime.timedelta(minutes=130)).distinct())
        projects = query.all()
        # For each project update task history for tasks that were not manually unlocked
        for project in projects:
            project_id = project[0]
            Task.auto_unlock_tasks(project_id)
Example #2
0
 def auto_unlock_tasks(project_id: int):
     Task.auto_unlock_tasks(project_id)