Calculate script optimizations, reset metrics script fixes, calculate script fixes
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user