Calculate script optimizations, reset metrics script fixes, calculate script fixes

This commit is contained in:
2025-01-16 19:48:08 -05:00
parent c9aefdc756
commit 87dc6b27f4
4 changed files with 946 additions and 639 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -51,18 +51,23 @@ async function resetMetrics() {
connection = await mysql.createConnection(dbConfig);
await connection.beginTransaction();
// Reset all metrics tables
// Drop all metrics tables
for (const table of METRICS_TABLES) {
console.log(`Truncating table: ${table}`);
console.log(`Dropping table: ${table}`);
try {
await connection.query(`TRUNCATE TABLE ${table}`);
console.log(`Successfully truncated: ${table}`);
await connection.query(`DROP TABLE IF EXISTS ${table}`);
console.log(`Successfully dropped: ${table}`);
} catch (err) {
console.error(`Error truncating ${table}:`, err.message);
console.error(`Error dropping ${table}:`, err.message);
throw err;
}
}
// Recreate all metrics tables from schema
const schemaSQL = fs.readFileSync(path.resolve(__dirname, '../db/metrics-schema.sql'), 'utf8');
await connection.query(schemaSQL);
console.log('All metrics tables recreated successfully');
await connection.commit();
console.log('All metrics tables reset successfully');
} catch (error) {