we have MVP
This commit is contained in:
parent
08633f1288
commit
2819487f00
20
main.py
20
main.py
|
@ -37,24 +37,30 @@ async def get_route():
|
||||||
result = engine.execute(select)
|
result = engine.execute(select)
|
||||||
data = []
|
data = []
|
||||||
for route in result:
|
for route in result:
|
||||||
data.append({"route": route})
|
data.append(route)
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
@app.post("/route")
|
@app.post("/route")
|
||||||
async def post_route(route: Route):
|
async def post_route(route: dict):
|
||||||
print(route)
|
print(route)
|
||||||
as_dict = route.dict()['route']
|
# as_dict = route.dict()
|
||||||
as_dict['id'] = "astoehsteaohus"
|
|
||||||
insert = text(
|
insert = text(
|
||||||
"""INSERT INTO
|
"""INSERT INTO
|
||||||
routes (id, creatorName, creationDate, name, creatorCharacter, startLocation, endLocation, checkpoints, dustPoints)
|
routes (id, "creatorName", "creationDate", name, "creatorCharacter", "startLocation", "endLocation", checkpoints, dustpoints)
|
||||||
VALUES
|
VALUES
|
||||||
(:id, :creatorName, :creationDate, :name, :creatorCharacter,
|
(:id, :creatorName, :creationDate, :name, :creatorCharacter,
|
||||||
CAST(:startLocation as jsonb),
|
CAST(:startLocation as jsonb),
|
||||||
CAST(:endLocation as jsonb),
|
CAST(:endLocation as jsonb),
|
||||||
CAST(:checkpoints as jsonb[]),
|
CAST(:checkpoints as jsonb[]),
|
||||||
CAST(:dustPoints as jsonb[]))"""
|
CAST(:dustpoints as jsonb[]))"""
|
||||||
).bindparams(**as_dict)
|
).bindparams(**route)
|
||||||
engine.execute(insert)
|
engine.execute(insert)
|
||||||
return HTTPStatus.OK
|
return HTTPStatus.OK
|
||||||
|
|
||||||
|
|
||||||
|
@app.get("/route/delete")
|
||||||
|
async def delete_routes():
|
||||||
|
delete = text("TRUNCATE TABLE routes")
|
||||||
|
engine.execute(delete)
|
||||||
|
return HTTPStatus.OK
|
||||||
|
|
|
@ -14,13 +14,13 @@ fi
|
||||||
# TODO move to alembic migrations
|
# TODO move to alembic migrations
|
||||||
psql $PGDATABASE << EOF
|
psql $PGDATABASE << EOF
|
||||||
CREATE TABLE routes ( \
|
CREATE TABLE routes ( \
|
||||||
id text,
|
id text PRIMARY KEY,
|
||||||
name text,
|
name text,
|
||||||
creatorName text,
|
"creatorName" text,
|
||||||
creatorCharacter int,
|
"creatorCharacter" int,
|
||||||
dustPoints jsonb[],
|
dustpoints jsonb[],
|
||||||
checkPoints jsonb[],
|
checkpoints jsonb[],
|
||||||
startLocation jsonb,
|
"startLocation" jsonb,
|
||||||
endLocation jsonb,
|
"endLocation" jsonb,
|
||||||
creationDate text
|
"creationDate" text
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue