From 8369e9eef212241516da9abfe9c4fc72cc1a1174 Mon Sep 17 00:00:00 2001 From: Ben Wilson Date: Sun, 23 Jul 2023 00:15:48 -0400 Subject: [PATCH] best diff on dashboard --- src/ORM/client/client.service.ts | 8 ++++++++ src/controllers/client/client.controller.ts | 3 +++ 2 files changed, 11 insertions(+) diff --git a/src/ORM/client/client.service.ts b/src/ORM/client/client.service.ts index bff0fb1..975cfdd 100644 --- a/src/ORM/client/client.service.ts +++ b/src/ORM/client/client.service.ts @@ -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 { return await this.clientRepository.find({ where: { diff --git a/src/controllers/client/client.controller.ts b/src/controllers/client/client.controller.ts index 9b64132..5ba5830 100644 --- a/src/controllers/client/client.controller.ts +++ b/src/controllers/client/client.controller.ts @@ -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) => {