Spaces:
Running
Running
Download mockData.js from CSNET/whoop-health-tracker-pro: direct link, hf CLI and curl.
- Browser
- Download file 10.6 kB
-
https://huggingface.co/spaces/CSNET/whoop-health-tracker-pro/resolve/main/mockData.js
- Command line
-
hf download hf://spaces/CSNET/whoop-health-tracker-pro/mockData.js
-
curl -L -o mockData.js https://huggingface.co/spaces/CSNET/whoop-health-tracker-pro/resolve/main/mockData.js
10.6 kB
| // 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 | |
| }; | |
| } |