Skip to content

Commit

Permalink
fix:error
Browse files Browse the repository at this point in the history
  • Loading branch information
rocknroll17 committed Nov 3, 2024
1 parent 556c835 commit 07877da
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Router/price.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def get_expected_price(request : Request, user_id: str, date : str = Query(...))
purchases = PurchaseService.get_purchase_histories_by_item_id(useritem.item_id)
if len(purchases) == 0:
item = ItemService.get_item(useritem.item_name)
price += item.base_price * item.base_count
price += item.base_price
else:
avg_count = round(sum([purchase.count for purchase in purchases]) / len(purchases))
avg_price = sum([purchase.price for purchase in purchases]) / len(purchases)
Expand All @@ -33,4 +33,5 @@ def get_expected_price(request : Request, user_id: str, date : str = Query(...))
except ValueError:
return JSONResponse(status_code=HTTP_400_BAD_REQUEST, content={"message": "Invalid date format"})
except Exception as e:
raise e
return JSONResponse(status_code=HTTP_500_INTERNAL_SERVER_ERROR, content={"message": str(e)})

0 comments on commit 07877da

Please sign in to comment.