def generate_cycle_tasks_notifs(): """Generate notifications for cycle task group object tasks on status change. Args: day (date): send notification date. """ with benchmark("generate notifications for cycle tasks"): day = date.today() - relativedelta.relativedelta(days=1) send_datetime = datetime.combine(day, SEND_TIME) updated_tasks = CycleTaskGroupObjectTask.query.filter( CycleTaskGroupObjectTask.updated_at >= send_datetime ).all() done_tasks = [] not_done_tasks = [] for obj in updated_tasks: if obj.is_done: done_tasks.append(obj) else: not_done_tasks.append(obj) done_tasks_notify(done_tasks, day) not_done_tasks_notify(not_done_tasks, day) db.session.commit()
def generate_cycle_tasks_notifs(): """Generate notifications for cycle task group object tasks on status change. Args: day (date): send notification date. """ with benchmark("generate notifications for cycle tasks"): day = date.today() - relativedelta.relativedelta(days=1) send_datetime = datetime.combine(day, SEND_TIME) updated_tasks = CycleTaskGroupObjectTask.query.filter( CycleTaskGroupObjectTask.updated_at >= send_datetime ).all() done_tasks = [] not_done_tasks = [] for obj in updated_tasks: if obj.is_done: done_tasks.append(obj) else: not_done_tasks.append(obj) done_tasks_notify(done_tasks, day) not_done_tasks_notify(not_done_tasks, day) db.session.commit()