New features
This commit is contained in:
parent
8981dc9615
commit
49a4ab05b3
1 changed files with 0 additions and 83 deletions
|
|
@ -95,89 +95,6 @@ export const db = {
|
||||||
FOR EACH ROW
|
FOR EACH ROW
|
||||||
EXECUTE FUNCTION update_updated_at_column()
|
EXECUTE FUNCTION update_updated_at_column()
|
||||||
`);
|
`);
|
||||||
|
|
||||||
// Generate test data for August 2024
|
|
||||||
await this.generateAugustTestData();
|
|
||||||
},
|
|
||||||
|
|
||||||
// Generate comprehensive test data for August 2024
|
|
||||||
async generateAugustTestData() {
|
|
||||||
const year = 2025;
|
|
||||||
const month = 8; // August
|
|
||||||
const daysInAugust = 31;
|
|
||||||
|
|
||||||
console.log('Generating test data for August 2024...');
|
|
||||||
|
|
||||||
for (let day = 1; day <= daysInAugust; day++) {
|
|
||||||
const date = new Date(year, month - 1, day); // month is 0-indexed
|
|
||||||
const dateStr = date.toISOString().split('T')[0];
|
|
||||||
|
|
||||||
// Generate realistic but varied exercise data
|
|
||||||
// Some days will be rest days (random 20% chance)
|
|
||||||
const isRestDay = Math.random() < 0.2;
|
|
||||||
|
|
||||||
let pushups = 0;
|
|
||||||
let situps = 0;
|
|
||||||
let plankTimeSeconds = 0;
|
|
||||||
let runDistanceKm = 0;
|
|
||||||
let hangups = 0;
|
|
||||||
|
|
||||||
if (!isRestDay) {
|
|
||||||
// Pushups: 10-50 range with some progression over the month
|
|
||||||
const progressionBonus = Math.floor(day / 3); // Slight improvement over time
|
|
||||||
pushups = Math.floor(Math.random() * 40) + 10 + progressionBonus;
|
|
||||||
|
|
||||||
// Situps: 15-60 range
|
|
||||||
situps = Math.floor(Math.random() * 45) + 15 + progressionBonus;
|
|
||||||
|
|
||||||
// Plank: 30-180 seconds
|
|
||||||
plankTimeSeconds = Math.floor(Math.random() * 150) + 30;
|
|
||||||
|
|
||||||
// Running: 0-8km, not every day (60% chance)
|
|
||||||
if (Math.random() < 0.6) {
|
|
||||||
runDistanceKm = Math.round((Math.random() * 7 + 1) * 100) / 100; // 1-8km with 2 decimal places
|
|
||||||
}
|
|
||||||
|
|
||||||
// Hangups: 3-20 range
|
|
||||||
hangups = Math.floor(Math.random() * 18) + 3;
|
|
||||||
|
|
||||||
// Weekend bonus (slightly higher values on weekends)
|
|
||||||
const dayOfWeek = date.getDay();
|
|
||||||
if (dayOfWeek === 0 || dayOfWeek === 6) {
|
|
||||||
// Sunday or Saturday
|
|
||||||
pushups = Math.floor(pushups * 1.2);
|
|
||||||
situps = Math.floor(situps * 1.2);
|
|
||||||
plankTimeSeconds = Math.floor(plankTimeSeconds * 1.1);
|
|
||||||
hangups = Math.floor(hangups * 1.1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Insert the data, using ON CONFLICT to avoid duplicates
|
|
||||||
try {
|
|
||||||
await this.query(
|
|
||||||
`
|
|
||||||
INSERT INTO daily_exercises (date, pushups, situps, plank_time_seconds, run_distance_km, hangups)
|
|
||||||
VALUES ($1, $2, $3, $4, $5, $6)
|
|
||||||
ON CONFLICT (date) DO UPDATE SET
|
|
||||||
pushups = EXCLUDED.pushups,
|
|
||||||
situps = EXCLUDED.situps,
|
|
||||||
plank_time_seconds = EXCLUDED.plank_time_seconds,
|
|
||||||
run_distance_km = EXCLUDED.run_distance_km,
|
|
||||||
hangups = EXCLUDED.hangups,
|
|
||||||
updated_at = CURRENT_TIMESTAMP
|
|
||||||
`,
|
|
||||||
[dateStr, pushups, situps, plankTimeSeconds, runDistanceKm, hangups]
|
|
||||||
);
|
|
||||||
|
|
||||||
console.log(
|
|
||||||
`Added data for ${dateStr}: pushups=${pushups}, situps=${situps}, plank=${plankTimeSeconds}s, run=${runDistanceKm}km, hangups=${hangups}`
|
|
||||||
);
|
|
||||||
} catch (error) {
|
|
||||||
console.error(`Failed to insert data for ${dateStr}:`, error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log('August 2024 test data generation completed!');
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// Close all connections
|
// Close all connections
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue