fix: remove logging from prisma client and fix users API routes

This commit is contained in:
2026-03-31 01:15:57 -07:00
parent 492a18aa1b
commit e0d159ad8d
4 changed files with 56 additions and 12 deletions
+53
View File
@@ -0,0 +1,53 @@
#!/usr/bin/env node
/**
* Recalculate all ELO ratings and partnership stats
*
* This script rebuilds all player stats and partnership stats from scratch
* by processing all matches in chronological order.
*/
const { PrismaClient } = require('@prisma/client');
const { recalculateAllElo } = require('../src/lib/elo-utils');
const prisma = new PrismaClient();
async function main() {
console.log('Starting ELO recalculation...');
console.log('This will delete all existing stats and rebuild them from match history.');
console.log('');
try {
// Confirm before proceeding
const readline = require('readline').createInterface({
input: process.stdin,
output: process.stdout
});
const confirm = await new Promise(resolve => {
readline.question('Are you sure you want to proceed? (yes/no): ', resolve);
});
readline.close();
if (confirm.toLowerCase() !== 'yes') {
console.log('Operation cancelled.');
return;
}
console.log('Recalculating stats...');
const result = await recalculateAllElo(prisma);
console.log('\nRecalculation complete!');
console.log(`- Matches processed: ${result.matchesProcessed}`);
console.log(`- Players updated: ${result.playersUpdated}`);
console.log(`- Partnerships updated: ${result.partnershipsUpdated}`);
} catch (error) {
console.error('Error during recalculation:', error);
process.exit(1);
} finally {
await prisma.$disconnect();
}
}
main();