refactor: establish standalone application boundary
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import date
|
||||
from http import HTTPStatus
|
||||
from urllib.parse import parse_qs
|
||||
|
||||
|
||||
class SentimentRoutesMixin:
|
||||
def _handle_sentiment_get(self, parsed) -> bool:
|
||||
if parsed.path == "/api/sentiment/history":
|
||||
query = parse_qs(parsed.query)
|
||||
trade_date = query.get("trade_date", [date.today().isoformat()])[0]
|
||||
try:
|
||||
limit = int(query.get("limit", ["20"])[0])
|
||||
self.send_json(self.application_service.sentiment_history(trade_date, limit))
|
||||
except (TypeError, ValueError) as exc:
|
||||
self.send_json({"error": str(exc)}, HTTPStatus.BAD_REQUEST)
|
||||
return True
|
||||
return False
|
||||
Reference in New Issue
Block a user