-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use latest PMAT (mostly caching stuff) #18
Conversation
|
||
|
||
@db_cache(max_age=timedelta(days=3)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought that in APIs, it makes sense to observe only the first call -- no benefit in observing every call from potentially many many users on frontend. That's why the db_cache decorator is above observe decorator.
@@ -56,17 +36,19 @@ def market_insights(market_id: HexAddress) -> MarketInsightsResponse: | |||
raise fastapi.HTTPException( | |||
status_code=404, detail=f"Market with id `{market_id}` not found." | |||
) | |||
except Exception as e: | |||
logger.error(f"Failed to fetch market for `{market_id}`: {e}") | |||
raise fastapi.HTTPException(status_code=500) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A little simplification thanks to this -- on unhandled errors, APIs usually raise 500 instead of catching it and returning a dummy response.
) | ||
except Exception as e: | ||
logger.error(f"Failed to get tavily_response for market `{market_id}`: {e}") | ||
tavily_response = None | ||
raise fastapi.HTTPException(status_code=500) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we want to inform the user that the market wasn't found? So probably raise a 404 (or any 4xx)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No description provided.