Ejemplo n.º 1
0
def api_generate_next_task():
    """ Generate next task to label
    """
    # try to find task is not presented in completions
    completions = db.get_completions_ids()
    for (task_id, task) in db.get_tasks().items():
        if task_id not in completions:
            log.info(msg='New task for labeling', extra=task)
            return make_response(jsonify(task), 200)

    # no tasks found
    return make_response('', 404)
Ejemplo n.º 2
0
def tasks_page():
    """ Tasks and completions page: tasks.html
    """
    global c
    c = load_config()
    label_config = open(c['label_config']).read()  # load editor config from XML
    task_ids = db.get_tasks().keys()
    completed_at = db.get_completed_at(task_ids)

    # sort by completed time
    task_ids = sorted([(i, completed_at[i] if i in completed_at else '9') for i in task_ids], key=lambda x: x[1])
    task_ids = [i[0] for i in task_ids]  # take only id back
    return flask.render_template('tasks.html', config=c, label_config=label_config,
                                 task_ids=task_ids, completions=db.get_completions_ids(),
                                 completed_at=completed_at)
Ejemplo n.º 3
0
def api_all_completion_ids():
    """ Get all completion ids
    """
    ids = db.get_completions_ids()
    return make_response(jsonify(ids), 200)