feat: add Phase 5 Progression & Analytics — smart suggestions, dashboard, schedule
Add auto-progression engine (ProgressionService) with rep increase, weight increase, deload, and felt-easy acceleration rules. Add AnalyticsService for user stats, exercise progress charts, and volume-by-day data. New dashboard and schedule routes with Chart.js visualizations. Progression badges shown inline on workout day view. Navigation updated with Dashboard and Schedule links. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
46
app/templates/pages/dashboard.html
Normal file
46
app/templates/pages/dashboard.html
Normal file
@@ -0,0 +1,46 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Dashboard -- SneakySwole{% endblock %}
|
||||
|
||||
{% block head_extra %}
|
||||
<script src="https://cdn.jsdelivr.net/npm/chart.js@4"></script>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<hgroup>
|
||||
<h1>Progress Dashboard</h1>
|
||||
{% if active_profile %}
|
||||
<p>{{ active_profile.display_name }}'s training overview</p>
|
||||
{% else %}
|
||||
<p>No profile selected -- <a href="/profiles">select one</a></p>
|
||||
{% endif %}
|
||||
</hgroup>
|
||||
|
||||
{% if stats %}
|
||||
<!-- Summary Stats -->
|
||||
<div class="grid">
|
||||
{% include "partials/stats_card.html" %}
|
||||
</div>
|
||||
|
||||
<!-- Volume by Day Chart -->
|
||||
<article>
|
||||
<header><h3>Volume by Workout Day</h3></header>
|
||||
{% include "partials/volume_chart.html" %}
|
||||
</article>
|
||||
|
||||
<!-- Exercise Progress Links -->
|
||||
<article>
|
||||
<header><h3>Per-Exercise Progress</h3></header>
|
||||
<ul>
|
||||
{% for exercise in exercises %}
|
||||
<li>
|
||||
<a href="/dashboard/exercise/{{ exercise.id }}">
|
||||
{{ exercise.name }}
|
||||
</a>
|
||||
<small> -- {{ exercise.workout_day }} Day</small>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</article>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
48
app/templates/pages/exercise_progress.html
Normal file
48
app/templates/pages/exercise_progress.html
Normal file
@@ -0,0 +1,48 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}{{ exercise.name }} Progress -- SneakySwole{% endblock %}
|
||||
|
||||
{% block head_extra %}
|
||||
<script src="https://cdn.jsdelivr.net/npm/chart.js@4"></script>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<hgroup>
|
||||
<h1>{{ exercise.name }}</h1>
|
||||
<p>{{ exercise.muscle_group }} | {{ exercise.workout_day }} Day</p>
|
||||
</hgroup>
|
||||
|
||||
<!-- Progression Suggestion -->
|
||||
{% if suggestion %}
|
||||
<article>
|
||||
<header><h3>Next Workout Suggestion</h3></header>
|
||||
<p>{{ suggestion.message }}</p>
|
||||
<div class="grid">
|
||||
<div>
|
||||
<small>Suggested Reps</small>
|
||||
<p style="font-size:1.5rem; font-weight:700;">
|
||||
{{ suggestion.suggested_reps }}
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
<small>Suggested Weight</small>
|
||||
<p style="font-size:1.5rem; font-weight:700;">
|
||||
{{ suggestion.suggested_weight }}
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
<small>Progression Type</small>
|
||||
<p><mark>{{ suggestion.progression_type }}</mark></p>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
{% endif %}
|
||||
|
||||
<!-- Progress Chart -->
|
||||
<article>
|
||||
<header><h3>Rep and Weight Trends</h3></header>
|
||||
{% include "partials/progress_chart.html" %}
|
||||
</article>
|
||||
|
||||
<a href="/dashboard" role="button" class="outline">Back to Dashboard</a>
|
||||
{% endblock %}
|
||||
50
app/templates/pages/schedule.html
Normal file
50
app/templates/pages/schedule.html
Normal file
@@ -0,0 +1,50 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}4-Week Schedule -- SneakySwole{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<hgroup>
|
||||
<h1>4-Week Schedule</h1>
|
||||
{% if active_profile %}
|
||||
<p>Schedule for: <strong>{{ active_profile.display_name }}</strong></p>
|
||||
{% else %}
|
||||
<p>No profile selected -- <a href="/profiles">select one</a></p>
|
||||
{% endif %}
|
||||
</hgroup>
|
||||
|
||||
{% for week in weeks %}
|
||||
<article>
|
||||
<header>
|
||||
<h3>Week {{ week.week_number }}</h3>
|
||||
</header>
|
||||
<div class="grid">
|
||||
{% for day in week.days %}
|
||||
<div style="text-align:center;
|
||||
padding:1rem;
|
||||
border-radius:0.5rem;
|
||||
{% if day.is_today %}
|
||||
border: 2px solid var(--pico-primary);
|
||||
{% endif %}
|
||||
{% if day.is_completed %}
|
||||
background: rgba(99, 102, 241, 0.15);
|
||||
{% endif %}">
|
||||
<strong>{{ day.workout_day.name }}</strong>
|
||||
<br>
|
||||
<small>{{ day.date.strftime('%b %d') }}</small>
|
||||
{% if day.is_completed %}
|
||||
<br><mark>Done</mark>
|
||||
{% endif %}
|
||||
{% if day.is_today %}
|
||||
<br><small><strong>Today</strong></small>
|
||||
{% endif %}
|
||||
<br>
|
||||
<a href="/workouts/{{ day.workout_day.name|lower|replace(' ', '-') }}"
|
||||
style="font-size:0.8rem;">
|
||||
Start
|
||||
</a>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</article>
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
@@ -19,6 +19,11 @@
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if suggestions and suggestions[exercise.id] %}
|
||||
{% set suggestion = suggestions[exercise.id] %}
|
||||
{% include "partials/progression_badge.html" %}
|
||||
{% endif %}
|
||||
|
||||
<details>
|
||||
<summary>Form Cues</summary>
|
||||
<p>{{ exercise.form_cues }}</p>
|
||||
|
||||
@@ -27,6 +27,8 @@
|
||||
</details>
|
||||
</li>
|
||||
<li><a href="/workouts">Workouts</a></li>
|
||||
<li><a href="/schedule">Schedule</a></li>
|
||||
<li><a href="/dashboard">Dashboard</a></li>
|
||||
<li><a href="/history">History</a></li>
|
||||
<li><a href="/exercises">Exercises</a></li>
|
||||
<li><a href="/profiles">Profiles</a></li>
|
||||
|
||||
56
app/templates/partials/progress_chart.html
Normal file
56
app/templates/partials/progress_chart.html
Normal file
@@ -0,0 +1,56 @@
|
||||
<canvas id="progress-chart" style="max-height:300px;"></canvas>
|
||||
<p id="progress-chart-empty" style="display:none;">No data yet.</p>
|
||||
<script>
|
||||
(function() {
|
||||
var data = {{ progress_data_json|safe }};
|
||||
|
||||
if (!data.dates || data.dates.length === 0) {
|
||||
document.getElementById('progress-chart').style.display = 'none';
|
||||
document.getElementById('progress-chart-empty').style.display = 'block';
|
||||
return;
|
||||
}
|
||||
|
||||
new Chart(document.getElementById('progress-chart'), {
|
||||
type: 'line',
|
||||
data: {
|
||||
labels: data.dates,
|
||||
datasets: [
|
||||
{
|
||||
label: 'Avg Reps',
|
||||
data: data.reps,
|
||||
borderColor: 'rgba(99, 102, 241, 1)',
|
||||
backgroundColor: 'rgba(99, 102, 241, 0.2)',
|
||||
yAxisID: 'y-reps',
|
||||
tension: 0.3
|
||||
},
|
||||
{
|
||||
label: 'Weight (lbs)',
|
||||
data: data.weights,
|
||||
borderColor: 'rgba(244, 63, 94, 1)',
|
||||
backgroundColor: 'rgba(244, 63, 94, 0.2)',
|
||||
yAxisID: 'y-weight',
|
||||
tension: 0.3
|
||||
}
|
||||
]
|
||||
},
|
||||
options: {
|
||||
responsive: true,
|
||||
interaction: { mode: 'index', intersect: false },
|
||||
scales: {
|
||||
'y-reps': {
|
||||
type: 'linear', display: true, position: 'left',
|
||||
title: { display: true, text: 'Reps', color: '#ccc' },
|
||||
ticks: { color: '#ccc' }
|
||||
},
|
||||
'y-weight': {
|
||||
type: 'linear', display: true, position: 'right',
|
||||
title: { display: true, text: 'Weight (lbs)', color: '#ccc' },
|
||||
ticks: { color: '#ccc' },
|
||||
grid: { drawOnChartArea: false }
|
||||
},
|
||||
x: { ticks: { color: '#ccc' } }
|
||||
}
|
||||
}
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
11
app/templates/partials/progression_badge.html
Normal file
11
app/templates/partials/progression_badge.html
Normal file
@@ -0,0 +1,11 @@
|
||||
{% if suggestion and suggestion.progression_type != "no_program" %}
|
||||
<div style="background: rgba(99, 102, 241, 0.1);
|
||||
border-left: 3px solid var(--pico-primary);
|
||||
padding: 0.5rem 1rem;
|
||||
margin-bottom: 0.5rem;
|
||||
border-radius: 0 0.25rem 0.25rem 0;">
|
||||
<small>
|
||||
<strong>Suggestion:</strong> {{ suggestion.message }}
|
||||
</small>
|
||||
</div>
|
||||
{% endif %}
|
||||
24
app/templates/partials/stats_card.html
Normal file
24
app/templates/partials/stats_card.html
Normal file
@@ -0,0 +1,24 @@
|
||||
<article>
|
||||
<header><h4>Sessions</h4></header>
|
||||
<p style="font-size:2rem; font-weight:700;">
|
||||
{{ stats.total_sessions }}
|
||||
</p>
|
||||
</article>
|
||||
<article>
|
||||
<header><h4>Total Volume</h4></header>
|
||||
<p style="font-size:2rem; font-weight:700;">
|
||||
{{ "{:,}".format(stats.total_volume) }} lbs
|
||||
</p>
|
||||
</article>
|
||||
<article>
|
||||
<header><h4>Total Sets</h4></header>
|
||||
<p style="font-size:2rem; font-weight:700;">
|
||||
{{ stats.total_sets }}
|
||||
</p>
|
||||
</article>
|
||||
<article>
|
||||
<header><h4>Streak</h4></header>
|
||||
<p style="font-size:2rem; font-weight:700;">
|
||||
{{ stats.current_streak }} week{{ "s" if stats.current_streak != 1 }}
|
||||
</p>
|
||||
</article>
|
||||
30
app/templates/partials/volume_chart.html
Normal file
30
app/templates/partials/volume_chart.html
Normal file
@@ -0,0 +1,30 @@
|
||||
<canvas id="volume-chart" style="max-height:300px;"></canvas>
|
||||
<script>
|
||||
(function() {
|
||||
var data = {{ volume_data_json|safe }};
|
||||
var labels = Object.keys(data);
|
||||
var values = Object.values(data);
|
||||
|
||||
new Chart(document.getElementById('volume-chart'), {
|
||||
type: 'bar',
|
||||
data: {
|
||||
labels: labels,
|
||||
datasets: [{
|
||||
label: 'Total Volume (lbs)',
|
||||
data: values,
|
||||
backgroundColor: 'rgba(99, 102, 241, 0.7)',
|
||||
borderColor: 'rgba(99, 102, 241, 1)',
|
||||
borderWidth: 1
|
||||
}]
|
||||
},
|
||||
options: {
|
||||
responsive: true,
|
||||
plugins: { legend: { display: false } },
|
||||
scales: {
|
||||
y: { beginAtZero: true, ticks: { color: '#ccc' } },
|
||||
x: { ticks: { color: '#ccc' } }
|
||||
}
|
||||
}
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
Reference in New Issue
Block a user