fitness: add weekly workout goal with streak counter on stats page
All checks were successful
CI / update (push) Successful in 2m3s
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:
18
src/models/FitnessGoal.ts
Normal file
18
src/models/FitnessGoal.ts
Normal 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;
|
||||
Reference in New Issue
Block a user