stats history for pair selector

This commit is contained in:
Oleg Sheynin
2026-01-28 23:27:52 +00:00
parent 76f9a80ad6
commit 38c3c73021
3 changed files with 68 additions and 36 deletions
+7 -4
View File
@@ -81,16 +81,18 @@ class PairSelector(NamedObject):
quality = self.engine_.quality_dicts()
if fmt == "json":
return web.json_response(quality)
return web.Response(text=self._render_quality_html(quality), content_type="text/html")
return web.Response(text=HtmlRenderer.render_data_quality_html(quality), content_type="text/html")
async def _on_pair_selection(self, request: web.Request) -> web.Response:
fmt = request.query.get("format", "html").lower()
pairs = self.engine_.pair_dicts()
if fmt == "json":
return web.json_response(pairs)
return web.Response(text=self._render_pairs_html(pairs), content_type="text/html")
return web.Response(text=HtmlRenderer.render_pair_selection_html(pairs), content_type="text/html")
def _render_quality_html(self, quality: List[Dict[str, Any]]) -> str:
class HtmlRenderer:
@staticmethod
def render_data_quality_html(quality: List[Dict[str, Any]]) -> str:
rows = "".join(
f"<tr>"
f"<td>{q.get('instrument','')}</td>"
@@ -126,7 +128,8 @@ class PairSelector(NamedObject):
</html>
"""
def _render_pairs_html(self, pairs: List[Dict[str, Any]]) -> str:
@staticmethod
def render_pair_selection_html(pairs: List[Dict[str, Any]]) -> str:
if not pairs:
body = "<p>No pairs available. Check data quality and try again.</p>"
else: