fitness: add weekly workout goal with streak counter on stats page
All checks were successful
CI / update (push) Successful in 2m3s

Store a per-user weekly workout target (1-14) in a new FitnessGoal model.
Compute consecutive-week streak from WorkoutSession history via a new
/api/fitness/goal endpoint. Display streak as a 4th lifetime card on the
stats page with an inline goal editor modal.
This commit is contained in:
2026-03-22 21:35:07 +01:00
parent f5420badc1
commit 69b3ac2aa4
5 changed files with 337 additions and 4 deletions

18
src/models/FitnessGoal.ts Normal file
View File

@@ -0,0 +1,18 @@
import mongoose from 'mongoose';
const FitnessGoalSchema = new mongoose.Schema(
{
username: { type: String, required: true, unique: true },
weeklyWorkouts: { type: Number, required: true, default: 4, min: 1, max: 14 }
},
{ timestamps: true }
);
interface IFitnessGoal {
username: string;
weeklyWorkouts: number;
}
let _model: mongoose.Model<IFitnessGoal>;
try { _model = mongoose.model<IFitnessGoal>("FitnessGoal"); } catch { _model = mongoose.model<IFitnessGoal>("FitnessGoal", FitnessGoalSchema); }
export const FitnessGoal = _model;