feat: add emojis to statistics tables and use formatted markdown durations for activity times
This commit is contained in:
@@ -2,7 +2,7 @@ import json
|
||||
from mcp.server.fastmcp import FastMCP, Context
|
||||
from mcp.types import TextContent, Annotations, EmbeddedResource, TextResourceContents
|
||||
from strava_mcp_server.strava_client import StravaClient
|
||||
from strava_mcp_server.utils import format_date_human
|
||||
from strava_mcp_server.utils import format_date_human, format_duration_markdown
|
||||
|
||||
|
||||
def register(mcp: FastMCP, strava: StravaClient) -> None:
|
||||
@@ -135,36 +135,37 @@ def register(mcp: FastMCP, strava: StravaClient) -> None:
|
||||
return {
|
||||
"count": s.get("count", 0),
|
||||
"distance": f"{s.get('distance', 0) / 1000:.1f} km",
|
||||
"moving_time": f"{s.get('moving_time', 0) / 3600:.1f} h",
|
||||
"moving_time_raw": s.get("moving_time", 0),
|
||||
"elevation_gain": f"{s.get('elevation_gain', 0):.0f} m",
|
||||
}
|
||||
|
||||
# Prepare structured data for Markdown
|
||||
all_time = {
|
||||
"Laufen": fmt_sport(stats.get("all_run_totals", {})),
|
||||
"Radfahren": fmt_sport(stats.get("all_ride_totals", {})),
|
||||
"Schwimmen": fmt_sport(stats.get("all_swim_totals", {})),
|
||||
"🏃 Laufen": fmt_sport(stats.get("all_run_totals", {})),
|
||||
"🚴 Radfahren": fmt_sport(stats.get("all_ride_totals", {})),
|
||||
"🏊 Schwimmen": fmt_sport(stats.get("all_swim_totals", {})),
|
||||
}
|
||||
ytd = {
|
||||
"Laufen": fmt_sport(stats.get("ytd_run_totals", {})),
|
||||
"Radfahren": fmt_sport(stats.get("ytd_ride_totals", {})),
|
||||
"Schwimmen": fmt_sport(stats.get("ytd_swim_totals", {})),
|
||||
"🏃 Laufen": fmt_sport(stats.get("ytd_run_totals", {})),
|
||||
"🚴 Radfahren": fmt_sport(stats.get("ytd_ride_totals", {})),
|
||||
"🏊 Schwimmen": fmt_sport(stats.get("ytd_swim_totals", {})),
|
||||
}
|
||||
recent = {
|
||||
"Laufen": fmt_sport(stats.get("recent_run_totals", {})),
|
||||
"Radfahren": fmt_sport(stats.get("recent_ride_totals", {})),
|
||||
"Schwimmen": fmt_sport(stats.get("recent_swim_totals", {})),
|
||||
"🏃 Laufen": fmt_sport(stats.get("recent_run_totals", {})),
|
||||
"🚴 Radfahren": fmt_sport(stats.get("recent_ride_totals", {})),
|
||||
"🏊 Schwimmen": fmt_sport(stats.get("recent_swim_totals", {})),
|
||||
}
|
||||
|
||||
markdown_summary = "### 📈 Trainingsstatistiken\n\n"
|
||||
|
||||
def create_table(title: str, data: dict):
|
||||
tbl = f"#### {title}\n"
|
||||
tbl += "| Sport | Aktivitäten | Distanz | Zeit | Höhenmeter |\n"
|
||||
tbl += "|-------|-------------|---------|------|------------|\n"
|
||||
tbl += "| 🏃 Sport | 🔢 Aktivitäten | 📐 Distanz | ⏱️ Zeit | 🏔️ Höhenmeter |\n"
|
||||
tbl += "|----------|----------------|-----------|--------|--------------|\n"
|
||||
for sport, s in data.items():
|
||||
if s["count"] > 0:
|
||||
tbl += f"| {sport} | {s['count']} | {s['distance']} | {s['moving_time']} | {s['elevation_gain']} |\n"
|
||||
time_md = format_duration_markdown(s["moving_time_raw"])
|
||||
tbl += f"| {sport} | {s['count']} | {s['distance']} | {time_md} | {s['elevation_gain']} |\n"
|
||||
return tbl + "\n"
|
||||
|
||||
markdown_summary += create_table("Letzte 4 Wochen", recent)
|
||||
|
||||
Reference in New Issue
Block a user