This commit is contained in:
Benjamin Wilson
2025-02-25 23:40:50 -05:00
parent 326a5a7b33
commit f8d1c61c1c
@@ -42,6 +42,10 @@ export class ClientStatisticsService {
} }
public async doBulkAsyncUpdate(){ public async doBulkAsyncUpdate(){
if(this.bulkAsyncUpdates.length < 1){
console.log('No client stats to update.')
return;
}
// Step 1: Prepare data for bulk update // Step 1: Prepare data for bulk update
const values = this.bulkAsyncUpdates.map(stat => const values = this.bulkAsyncUpdates.map(stat =>
`('${stat.clientId}', ${stat.time}, ${stat.shares ?? 0}, ${stat.acceptedCount ?? 0}, NOW())` `('${stat.clientId}', ${stat.time}, ${stat.shares ?? 0}, ${stat.acceptedCount ?? 0}, NOW())`
@@ -73,6 +77,7 @@ export class ClientStatisticsService {
try { try {
await this.clientStatisticsRepository.query(query); await this.clientStatisticsRepository.query(query);
console.log(`Bulk updated ${this.bulkAsyncUpdates.length} statistics`)
} catch (error) { } catch (error) {
console.error('Bulk update failed:', error.message, query); console.error('Bulk update failed:', error.message, query);
throw error; throw error;