name issue

This commit is contained in:
arcbtc 2023-12-28 16:52:49 +00:00
parent aae9a0d33a
commit d5d2e738b2
2 changed files with 9 additions and 9 deletions

View file

@ -12,18 +12,18 @@ from fastapi.responses import JSONResponse
db = Database("ext_tempextension")
temp_ext: APIRouter = APIRouter(
prefix="/tempextension", tags=["Temp"]
prefix="/temp", tags=["Temp"]
)
temp_static_files = [
{
"path": "/tempextension/static",
"name": "tempextension_static",
"path": "/temp/static",
"name": "temp_static",
}
]
def template_renderer():
return template_renderer(["tempextension/templates"])
return template_renderer(["temp/templates"])
from .lnurl import *
from .tasks import wait_for_paid_invoices

10
crud.py
View file

@ -11,7 +11,7 @@ async def create_temp(wallet_id: str, data: CreateTempData) -> Temp:
temp_id = urlsafe_short_hash()
await db.execute(
"""
INSERT INTO tempextension.tempextension (id, wallet, name, total)
INSERT INTO tempextension.temp (id, wallet, name, total)
VALUES (?, ?, ?, ?)
""",
(
@ -29,7 +29,7 @@ async def create_temp(wallet_id: str, data: CreateTempData) -> Temp:
async def get_temp(temp_id: str) -> Optional[Temp]:
row = await db.fetchone("SELECT * FROM tempextension.tempextension WHERE id = ?", (temp_id,))
row = await db.fetchone("SELECT * FROM tempextension.temp WHERE id = ?", (temp_id,))
return Temp(**row) if row else None
async def get_temps(wallet_ids: Union[str, List[str]]) -> List[Temp]:
@ -38,18 +38,18 @@ async def get_temps(wallet_ids: Union[str, List[str]]) -> List[Temp]:
q = ",".join(["?"] * len(wallet_ids))
rows = await db.fetchall(
f"SELECT * FROM tempextension.tempextension WHERE wallet IN ({q})", (*wallet_ids,)
f"SELECT * FROM tempextension.temp WHERE wallet IN ({q})", (*wallet_ids,)
)
return [Temp(**row) for row in rows]
async def update_temp(temp_id: str, **kwargs) -> Temp:
q = ", ".join([f"{field[0]} = ?" for field in kwargs.items()])
await db.execute(
f"UPDATE tempextension.tempextension SET {q} WHERE id = ?", (*kwargs.values(), temp_id)
f"UPDATE tempextension.temp SET {q} WHERE id = ?", (*kwargs.values(), temp_id)
)
temp = await get_temp(temp_id)
assert temp, "Newly updated temp couldn't be retrieved"
return temp
async def delete_temp(temp_id: str) -> None:
await db.execute("DELETE FROM tempextension.tempextension WHERE id = ?", (temp_id,))
await db.execute("DELETE FROM tempextension.temp WHERE id = ?", (temp_id,))