mirror of
https://github.com/lnbits/lnbits-legend.git
synced 2025-02-25 07:07:48 +01:00
format
This commit is contained in:
parent
ad98cb0d45
commit
ee47575431
3 changed files with 15 additions and 10 deletions
|
@ -201,12 +201,15 @@ async def get_diagonalley_stalls(wallet_ids: Union[str, List[str]]) -> List[Stal
|
|||
)
|
||||
return [Stalls(**row) for row in rows]
|
||||
|
||||
async def get_diagonalley_stalls_by_ids(stall_ids: Union[str, List[str]]) -> List[Stalls]:
|
||||
|
||||
async def get_diagonalley_stalls_by_ids(
|
||||
stall_ids: Union[str, List[str]]
|
||||
) -> List[Stalls]:
|
||||
q = ",".join(["?"] * len(stall_ids))
|
||||
rows = await db.fetchall(
|
||||
f"SELECT * FROM diagonalley.stalls WHERE id IN ({q})", (*stall_ids,)
|
||||
)
|
||||
return [Stalls(**row) for row in rows]
|
||||
return [Stalls(**row) for row in rows]
|
||||
|
||||
|
||||
async def delete_diagonalley_stall(stall_id: str) -> None:
|
||||
|
@ -353,10 +356,10 @@ async def get_diagonalley_market(market_id: str) -> Optional[Market]:
|
|||
async def get_diagonalley_market_stalls(market_id: str):
|
||||
rows = await db.fetchall(
|
||||
"SELECT * FROM diagonalley.market_stalls WHERE marketid = ?", (market_id,)
|
||||
)
|
||||
)
|
||||
|
||||
ids = [row["stallid"] for row in rows]
|
||||
|
||||
ids = [row["stallid"] for row in rows]
|
||||
|
||||
return await get_diagonalley_stalls_by_ids(ids)
|
||||
|
||||
|
||||
|
|
|
@ -64,15 +64,17 @@ async def display(request: Request, stall_id):
|
|||
@diagonalley_ext.get("/market/{market_id}", response_class=HTMLResponse)
|
||||
async def display(request: Request, market_id):
|
||||
market = await get_diagonalley_market(market_id)
|
||||
|
||||
|
||||
if not market:
|
||||
raise HTTPException(
|
||||
status_code=HTTPStatus.NOT_FOUND, detail="Marketplace doesn't exist."
|
||||
)
|
||||
|
||||
|
||||
stalls = await get_diagonalley_market_stalls(market_id)
|
||||
stalls_ids = [stall.id for stall in stalls]
|
||||
products = [product.dict() for product in await get_diagonalley_products(stalls_ids)]
|
||||
products = [
|
||||
product.dict() for product in await get_diagonalley_products(stalls_ids)
|
||||
]
|
||||
|
||||
return diagonalley_renderer().TemplateResponse(
|
||||
"diagonalley/market.html",
|
||||
|
@ -80,6 +82,6 @@ async def display(request: Request, market_id):
|
|||
"request": request,
|
||||
"market": market,
|
||||
"stalls": [stall.dict() for stall in stalls],
|
||||
"products": products
|
||||
"products": products,
|
||||
},
|
||||
)
|
||||
|
|
|
@ -444,7 +444,7 @@ async def api_diagonalley_markets(wallet: WalletTypeInfo = Depends(get_key_type)
|
|||
async def api_diagonalley_market_stalls(market_id: str):
|
||||
stall_ids = await get_diagonalley_market_stalls(market_id)
|
||||
return stall_ids
|
||||
|
||||
|
||||
|
||||
@diagonalley_ext.post("/api/v1/markets")
|
||||
@diagonalley_ext.put("/api/v1/markets/{market_id}")
|
||||
|
|
Loading…
Add table
Reference in a new issue