best diff on dashboard

This commit is contained in:
Ben Wilson
2023-07-23 00:15:48 -04:00
parent e2a0d16577
commit 8369e9eef2
2 changed files with 11 additions and 0 deletions
+8
View File
@@ -45,6 +45,14 @@ export class ClientService {
return await this.clientRepository.count();
}
public async getBestDiff(address: string) {
const res = await this.clientRepository.createQueryBuilder('client')
.select('MAX(client.bestDifficulty)', 'bestDifficulty')
.where('client.address = :address', { address })
.withDeleted()
.getRawOne();
return res?.bestDifficulty;
}
public async getByAddress(address: string): Promise<ClientEntity[]> {
return await this.clientRepository.find({
where: {
@@ -20,7 +20,10 @@ export class ClientController {
const chartData = await this.clientStatisticsService.getChartDataForAddress(address);
const bestDifficulty = await this.clientService.getBestDiff(address);
return {
bestDifficulty,
workersCount: workers.length,
workers: await Promise.all(
workers.map(async (worker) => {