Skip to content

Commit

Permalink
returns a JSON response if desired result is not found
Browse files Browse the repository at this point in the history
  • Loading branch information
kirtanchandak committed Mar 1, 2025
1 parent 7617033 commit 1d95d37
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions folksonomy/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,14 @@ async def product_stats(response: Response,
# )
# out2 = await cur.fetchone()
# import pdb;pdb.set_trace()

if not out or not out[0]:
return JSONResponse(
status_code=200,
content={"message": "No products found matching the given filters."},
headers={"x-pg-timing": timing}
)

return JSONResponse(status_code=200, content=out[0], headers={"x-pg-timing":timing})


Expand Down Expand Up @@ -340,6 +348,14 @@ async def product_tags_list(response: Response,
(product, owner),
)
out = await cur.fetchone()

if not out or not out[0]:
return JSONResponse(
status_code=200,
content={"message": "No product found matching the given tags."},
headers={"x-pg-timing": timing}
)

return JSONResponse(status_code=200, content=out[0], headers={"x-pg-timing": timing})


Expand Down

0 comments on commit 1d95d37

Please sign in to comment.