Files
Stride/app/stats_presets.py
T

103 lines
5.8 KiB
Python

"""Editable analyses; never tied to a fixed calendar date."""
PRESETS = [
{
"name": "HR in steady segments",
"category": "Effort & recovery",
"description": "Match five-minute moving segments by pace, speed consistency and HR coverage.",
"query": 'segments\n during last 12 weeks\n reduce by run min 3 min\n where pace between 5:20 and 5:40 /km\n and pace_variability <= 5 %\n and sensor_coverage >= 80 %\n and duration >= 4 min\n summarize weighted_mean(heart_rate) as "Steady-segment HR"\n by week\n compare none\n baseline previous 90 days\n flag above baseline 1.5 sd min 5 runs sustained 2 buckets\n chart line',
},
{
"name": "Speed/HR decoupling",
"category": "Effort & recovery",
"description": "First-half versus second-half efficiency, alongside pace consistency and HR coverage.",
"query": "runs\n during last 12 weeks\n where duration >= 30 min\n and sensor_coverage >= 80 %\n summarize heart_rate_drift, pace_variability\n by week\n compare none\n chart line\n reference heart_rate_drift = 0 %",
},
{
"name": "Easy and harder volume",
"category": "Training",
"description": "Partition weekly distance by a heart-rate threshold you can edit.",
"query": 'runs\n during last 12 weeks\n summarize sum(distance)\n by week\n compare none\n cohort "Lower HR" where heart_rate <= 145 bpm\n cohort "Higher HR" where heart_rate > 145 bpm\n chart stacked',
},
{
"name": "Lap consistency",
"category": "Distributions",
"description": "Distribution of recorded lap paces, grouped by week.",
"query": "laps\n during last 12 weeks\n summarize pace\n by week\n compare none\n chart box",
},
{
"name": "Year over year",
"category": "Training",
"description": "Compare monthly volume with the same local-date period last year.",
"query": "runs\n during last 6 months\n summarize distance\n by month\n compare previous year\n chart area",
},
{
"name": "HR at comparable pace",
"category": "Effort & recovery",
"description": "Match pace and hills; compare weekly HR with your earlier matched runs.",
"query": 'runs\n during last 12 weeks\n where pace between 5:20 and 5:40 /km\n and elevation_per_km <= 10 m/km\n and has heart_rate\n summarize weighted_mean(heart_rate) as "Matched-pace HR"\n by week\n compare none\n baseline previous 90 days\n flag above baseline 1.5 sd min 3 runs sustained 2 buckets\n chart line',
},
{
"name": "Pace at comparable HR",
"category": "Effort & recovery",
"description": "Track pace within a consistent heart-rate band.",
"query": "runs\n during last 6 months\n where heart_rate between 140 and 150 bpm\n and elevation_per_km <= 10 m/km\n summarize weighted_mean(pace)\n by week\n compare none\n baseline previous 90 days\n chart line",
},
{
"name": "Workload context",
"category": "Training",
"description": "Rolling 7- and 28-day distance alongside every run.",
"query": "runs\n during last 12 weeks\n summarize rolling_7d_distance, rolling_28d_distance\n by run\n sort by date asc\n compare none\n chart line\n display overlay",
},
{
"name": "Weekly volume",
"category": "Training",
"description": "Distance and run frequency with the previous period.",
"query": 'runs\n during last 12 weeks\n summarize sum(distance) as "Weekly distance", count()\n by week\n compare previous period\n chart bar',
},
{
"name": "Training calendar",
"category": "Training",
"description": "A daily distance heatmap with drill-down to each day's runs.",
"query": "runs\n during last 6 months\n summarize distance\n by day\n compare none\n chart heatmap",
},
{
"name": "Pace consistency",
"category": "Distributions",
"description": "Weekly pace distributions, including quartiles and range.",
"query": "runs\n during last 12 weeks\n summarize pace\n by week\n compare none\n chart box",
},
{
"name": "Run distance distribution",
"category": "Distributions",
"description": "See the mix of short, medium and long runs.",
"query": "runs\n during last 6 months\n summarize distance\n by all\n compare none\n chart histogram",
},
{
"name": "Effort relationships",
"category": "Relationships",
"description": "Pace versus HR, colored by terrain and sized by distance.",
"query": "runs\n during last 6 months\n summarize pace, heart_rate\n by week\n compare none\n plot pace vs heart_rate\n color by elevation_per_km\n size by distance",
},
{
"name": "Custom rolling effort",
"category": "Effort & recovery",
"description": "A 14-day mean HR calculated from complete history before filtering.",
"query": "runs\n during last 12 weeks\n let hr_14d = rolling_mean(heart_rate, 14 days)\n summarize hr_14d, heart_rate\n by run\n sort by date asc\n compare none\n chart line\n display overlay",
},
{
"name": "Weekday patterns",
"category": "Distributions",
"description": "Compare typical distance and pace by weekday.",
"query": "runs\n during last 6 months\n summarize median(distance), median(pace), count()\n by weekday\n having count() >= 3 runs\n compare none\n chart bar",
},
]
# Editable advanced examples. No account observations or inferred HR boundaries.
from .training_signals import signal_queries
PRESETS.extend({"name": d["name"], "category": "Deep training signals",
"description": d["notes"], "query": d["query"]}
for d in signal_queries())