sum hashrate

This commit is contained in:
Ben Wilson
2023-08-06 18:16:48 -04:00
parent 24538d34ce
commit 62f528d55f
5 changed files with 15 additions and 30 deletions
+2 -1
View File
@@ -29,7 +29,8 @@ export class ClientEntity extends TrackedEntity {
@Column({ type: 'real', default: 0 })
bestDifficulty: number
@Column({ default: 0 })
hashRate: number;
}
+3 -2
View File
@@ -30,8 +30,8 @@ export class ClientService {
.execute();
}
public async heartbeat(address: string, clientName: string, sessionId: string) {
return await this.clientRepository.update({ address, clientName, sessionId }, { deletedAt: null, updatedAt: new Date() });
public async heartbeat(address: string, clientName: string, sessionId: string, hashRate: number) {
return await this.clientRepository.update({ address, clientName, sessionId }, { hashRate, deletedAt: null, updatedAt: new Date() });
}
// public async save(client: Partial<ClientEntity>) {
@@ -111,6 +111,7 @@ export class ClientService {
.select('client.userAgent as userAgent')
.addSelect('COUNT(client.userAgent)', 'count')
.addSelect('MAX(client.bestDifficulty)', 'bestDifficulty')
.addSelect('SUM(client.hashRate)', 'totalHashRate')
.groupBy('client.userAgent')
.orderBy('count', 'DESC')
.getRawMany();