Spaces:
Running
Running
File size: 10,638 Bytes
28f4aa5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 | // Mock Data Generator for WHOOP Health Tracker
// This file generates realistic mock data for all health metrics
// Mock Data Functions
function generateMockData() {
return {
recovery: generateRecoveryData(),
sleep: generateSleepData(),
strain: generateStrainData(),
journal: generateJournalData()
};
}
// Generate Recovery Data
function generateRecoveryData() {
const days = 30;
const data = [];
for (let i = days - 1; i >= 0; i--) {
const date = new Date();
date.setDate(date.getDate() - i);
// Generate correlated data for realism
const baseRecovery = 70 + Math.sin(i / 7) * 15;
const recoveryScore = Math.max(0, Math.min(100, baseRecovery + (Math.random() - 0.5) * 20));
data.push({
date: date.toISOString().split('T')[0],
recoveryScore: Math.round(recoveryScore),
hrv: Math.round(40 + recoveryScore * 0.3 + (Math.random() - 0.5) * 10),
rhr: Math.round(70 - recoveryScore * 0.1 + (Math.random() - 0.5) * 5),
respRate: Math.round(14 + (100 - recoveryScore) * 0.05 + (Math.random() - 0.5) * 2),
skinTemp: Math.round(90 + (100 - recoveryScore) * 0.1 + (Math.random() - 0.5) * 2),
restingHeartRate: Math.round(55 + (100 - recoveryScore) * 0.2 + (Math.random() - 0.5) * 3)
});
}
return data;
}
// Generate Sleep Data
function generateSleepData() {
const days = 30;
const data = [];
for (let i = days - 1; i >= 0; i--) {
const date = new Date();
date.setDate(date.getDate() - i);
const totalSleep = 6.5 + Math.random() * 2.5;
const deepSleep = totalSleep * (0.15 + Math.random() * 0.1);
const remSleep = totalSleep * (0.20 + Math.random() * 0.1);
const lightSleep = totalSleep - deepSleep - remSleep - (Math.random() * 0.5);
const awakeTime = Math.random() * 0.5;
data.push({
date: date.toISOString().split('T')[0],
sleepPerformance: Math.round(70 + Math.random() * 30),
sleepDuration: Number(totalSleep.toFixed(1)),
timeInBed: Number((totalSleep + 0.5 + Math.random() * 0.5).toFixed(1)),
sleepStages: {
deep: Number(deepSleep.toFixed(1)),
rem: Number(remSleep.toFixed(1)),
light: Number(lightSleep.toFixed(1)),
awake: Number(awakeTime.toFixed(1))
},
efficiency: Math.round(85 + Math.random() * 15),
latency: Math.round(5 + Math.random() * 15),
disturbances: Math.floor(Math.random() * 5),
sleepDebt: Number((Math.random() * 3).toFixed(1))
});
}
return data;
}
// Generate Strain Data
function generateStrainData() {
const days = 30;
const data = [];
const activityTypes = ['Running', 'Weight Training', 'Yoga', 'Cycling', 'Swimming', 'HIIT', 'Walking', 'Sports'];
for (let i = days - 1; i >= 0; i--) {
const date = new Date();
date.setDate(date.getDate() - i);
const dailyStrain = Math.floor(Math.random() * 18) + 3;
const numActivities = Math.floor(Math.random() * 3) + 1;
const activities = [];
for (let j = 0; j < numActivities; j++) {
activities.push({
type: activityTypes[Math.floor(Math.random() * activityTypes.length)],
duration: Math.floor(Math.random() * 90) + 15,
strainScore: Math.floor(Math.random() * 10) + 1,
calories: Math.floor(Math.random() * 400) + 100,
avgHR: Math.floor(Math.random() * 50) + 100,
maxHR: Math.floor(Math.random() * 40) + 140
});
}
data.push({
date: date.toISOString().split('T')[0],
dailyStrain: dailyStrain,
maxHR: Math.floor(Math.random() * 50) + 140,
avgHR: Math.floor(Math.random() * 30) + 80,
calories: Math.floor(Math.random() * 1000) + 500,
activeTime: dailyStrain * 15 + Math.floor(Math.random() * 60),
restingTime: 1440 - (dailyStrain * 15) - Math.floor(Math.random() * 60),
activities: activities,
heartRateZones: {
zone1: Math.floor(Math.random() * 60) + 30,
zone2: Math.floor(Math.random() * 40) + 20,
zone3: Math.floor(Math.random() * 30) + 10,
zone4: Math.floor(Math.random() * 20) + 5,
zone5: Math.floor(Math.random() * 10) + 2
}
});
}
return data;
}
// Generate Journal Data
function generateJournalData() {
const entries = [];
const behaviors = ['Alcohol', 'Caffeine', 'Stress', 'Meditation', 'Nap', 'Stretching'];
for (let i = 14; i >= 0; i--) {
const date = new Date();
date.setDate(date.getDate() - i);
const entry = {
date: date.toISOString().split('T')[0],
behaviors: {},
notes: getRandomJournalNote(),
mood: Math.floor(Math.random() * 5) + 1,
energy: Math.floor(Math.random() * 5) + 1,
stress: Math.floor(Math.random() * 5) + 1
};
// Add random behaviors
behaviors.forEach(behavior => {
if (Math.random() > 0.5) {
entry.behaviors[behavior] = {
value: getRandomBehaviorValue(behavior),
impact: (Math.random() - 0.5) * 20
};
}
});
entries.push(entry);
}
return entries;
}
// Helper Functions
function getRandomJournalNote() {
const notes = [
"Feeling great after a good night's sleep!",
"Tough workout today, feeling tired but accomplished.",
"Stressful day at work, need to focus on recovery.",
"Energy levels are high, ready to take on the day.",
"Felt a bit off today, probably due to poor sleep.",
"Excellent recovery score, training is paying off.",
"Needed extra rest today after yesterday's intensity.",
"Morning routine is really helping with my recovery."
];
return notes[Math.floor(Math.random() * notes.length)];
}
function getRandomBehaviorValue(behavior) {
const values = {
Alcohol: ['None', 'Light (1-2)', 'Moderate (3-4)', 'Heavy (5+)'],
Caffeine: ['None', 'Low (1 cup)', 'Moderate (2-3 cups)', 'High (4+ cups)'],
Stress: ['Low', 'Moderate', 'High'],
Meditation: ['No', 'Yes (5-10 min)', 'Yes (15-20 min)', 'Yes (20+ min)'],
Nap: ['No', 'Short (0-30 min)', 'Medium (30-60 min)', 'Long (60+ min)'],
Stretching: ['No', 'Light (5-10 min)', 'Moderate (10-20 min)', 'Extensive (20+ min)']
};
const behaviorValues = values[behavior] || ['Yes', 'No'];
return behaviorValues[Math.floor(Math.random() * behaviorValues.length)];
}
// Coach Response Templates
const coachResponses = {
recovery: [
"Based on your current recovery score, I recommend {activity} today.",
"Your HRV is {hrv_trend}, which indicates {recovery_status}.",
"With a recovery score of {score}%, consider {recommendation}."
],
workout: [
"Given yesterday's strain of {strain}, today should be a {intensity} day.",
"Your heart rate variability suggests you're ready for {workout_type}.",
"Based on your sleep quality, I recommend {activity_duration} of {activity_type}."
],
sleep: [
"You slept {hours} hours with {performance}% efficiency. {sleep_advice}",
"Your sleep debt is {debt} hours. Try to {sleep_recommendation}.",
"Your sleep consistency is {consistency}%. {sleep_tip}"
],
strain: [
"Your daily strain of {strain} is in the {zone} zone. {strain_advice}",
"You spent {time} in Zone 5 today. {hr_advice}",
"Your strain distribution shows {pattern}. {recommendation}"
]
};
// Generate Personalized Coach Response
function generateCoachResponse(type, metrics) {
const templates = coachResponses[type];
const template = templates[Math.floor(Math.random() * templates.length)];
return template
.replace('{activity}', metrics.recoveryScore > 80 ? 'high-intensity training' : metrics.recoveryScore > 60 ? 'moderate exercise' : 'active recovery')
.replace('{hrv_trend}', metrics.hrv > 50 ? 'trending upward' : 'lower than usual')
.replace('{recovery_status}', metrics.recoveryScore > 80 ? 'excellent recovery' : metrics.recoveryScore > 60 ? 'moderate recovery' : 'need for recovery')
.replace('{score}', metrics.recoveryScore)
.replace('{recommendation}', metrics.recoveryScore > 80 ? 'challenging yourself' : metrics.recoveryScore > 60 ? 'a balanced workout' : 'focusing on recovery')
.replace('{strain}', metrics.dailyStrain)
.replace('{intensity}', metrics.dailyStrain > 15 ? 'active recovery' : metrics.dailyStrain > 10 ? 'moderate' : 'light')
.replace('{workout_type}', metrics.recoveryScore > 80 ? 'interval training' : 'steady-state cardio')
.replace('{activity_duration}', '45 minutes')
.replace('{activity_type}', 'cardio and strength training')
.replace('{hours}', metrics.sleepDuration)
.replace('{performance}', metrics.sleepPerformance)
.replace('{sleep_advice}', metrics.sleepDuration < 7 ? 'Try to get more sleep tonight.' : 'Great job on sleep duration!')
.replace('{debt}', metrics.sleepDebt)
.replace('{sleep_recommendation}', 'go to bed 30 minutes earlier tonight')
.replace('{consistency}', '85')
.replace('{sleep_tip}', 'Keep a consistent bedtime routine.')
.replace('{zone}', metrics.dailyStrain > 15 ? 'high' : metrics.dailyStrain > 10 ? 'moderate' : 'low')
.replace('{strain_advice}', metrics.dailyStrain > 15 ? 'Make sure to recover well tomorrow.' : 'Good job balancing activity and rest.')
.replace('{time}', '15 minutes')
.replace('{hr_advice}', 'Ensure proper cool-down and hydration.')
.replace('{pattern}', 'good balance across zones')
.replace('{recommendation}', 'Continue with your current training approach.');
}
// Export for use in other files
if (typeof module !== 'undefined' && module.exports) {
module.exports = {
generateMockData,
generateRecoveryData,
generateSleepData,
generateStrainData,
generateJournalData,
generateCoachResponse
};
} |