Exemplo n.º 1
0
async def set_off_progress(request: Request, id):
    await request.app.todo_db.update(
        f"""
            UPDATE public.to_do_list
            SET is_in_progress = False, updated_at = NOW()
            WHERE id = $1
            """, (id, ))
    return http_responses.http_ok(f'Note {id} set off progress')
Exemplo n.º 2
0
async def set_undone(request: Request, id):
    await request.app.todo_db.update(
        f"""
            UPDATE public.to_do_list
            SET is_finished = False, finished_at = Null, updated_at = NOW()
            WHERE id = $1
            """, (id, ))
    return http_responses.http_ok(f'Note {id} set undone')
Exemplo n.º 3
0
async def ping(request: Request):
    try:
        await request.app.todo_db.first("select 1")
        return http_responses.http_ok({'ok'})
    except:
        return http_responses.http_bad_request('no database connection')
Exemplo n.º 4
0
async def del_by_id(request: Request, id):
    await request.app.todo_db.update(
        "DELETE FROM public.to_do_list WHERE id = $1", (id, ))
    return http_responses.http_ok(f'Note {id} was DELETED')
Exemplo n.º 5
0
async def edit(request: Request, id):
    payload = dict(request.json)
    query, data = scripts.prepare_todo_list_update(payload, id)
    await request.app.todo_db.update(query, list(data.values()))
    return http_responses.http_ok(f'Note {id} was updated')
Exemplo n.º 6
0
async def add(request: Request):
    payload = dict(request.json)
    query, data = scripts.prepare_todo_list_insert(payload)
    await request.app.todo_db.insert(query, data.values())
    return http_responses.http_ok('Note was added')