Man, broken
This commit is contained in:
parent
e53ccb04ac
commit
274615f0b3
4 changed files with 7 additions and 7 deletions
|
|
@ -626,11 +626,11 @@ async def create_admin_settings(super_user: str, new_settings: dict):
|
||||||
# -------
|
# -------
|
||||||
|
|
||||||
|
|
||||||
async def create_tinyurl(domain: str, conn: Optional[Connection] = None):
|
async def create_tinyurl(domain: str, endless: bool, conn: Optional[Connection] = None):
|
||||||
tinyurl_id = uuid4().hex[:8]
|
tinyurl_id = uuid4().hex[:8]
|
||||||
await (conn or db).execute(
|
await (conn or db).execute(
|
||||||
f"INSERT INTO tiny_url (id, url) VALUES (?, ?)",
|
f"INSERT INTO tiny_url (id, url, endless) VALUES (?, ?, ?)",
|
||||||
(tinyurl_id, domain),
|
(tinyurl_id, domain, endless,),
|
||||||
)
|
)
|
||||||
return await get_tinyurl(tinyurl_id)
|
return await get_tinyurl(tinyurl_id)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -278,7 +278,7 @@ async def m009_create_tinyurl_table(db):
|
||||||
id TEXT PRIMARY KEY,
|
id TEXT PRIMARY KEY,
|
||||||
url TEXT,
|
url TEXT,
|
||||||
endless BOOL NOT NULL DEFAULT false,
|
endless BOOL NOT NULL DEFAULT false,
|
||||||
time TIMESTAMP NOT NULL DEFAULT {db.timestamp_now},
|
time TIMESTAMP NOT NULL DEFAULT {db.timestamp_now}
|
||||||
);
|
);
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -223,4 +223,4 @@ class TinyURL(BaseModel):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_row(cls, row: Row):
|
def from_row(cls, row: Row):
|
||||||
return cls(id=row["id"], url=row["url"])
|
return cls(dict(row))
|
||||||
|
|
|
||||||
|
|
@ -715,11 +715,11 @@ async def websocket_update_get(item_id: str, data: str):
|
||||||
|
|
||||||
|
|
||||||
@core_app.post("/api/v1/tinyurl")
|
@core_app.post("/api/v1/tinyurl")
|
||||||
async def api_create_tinyurl(url: str):
|
async def api_create_tinyurl(url: str, endless: Optional[bool] = False):
|
||||||
tinyurl = await get_tinyurl_by_url(url)
|
tinyurl = await get_tinyurl_by_url(url)
|
||||||
if tinyurl:
|
if tinyurl:
|
||||||
return tinyurl
|
return tinyurl
|
||||||
return await create_tinyurl(url)
|
return await create_tinyurl(url, endless)
|
||||||
|
|
||||||
|
|
||||||
@core_app.get("/api/v1/tinyurl/{tinyurl_id}")
|
@core_app.get("/api/v1/tinyurl/{tinyurl_id}")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue