This commit is contained in:
Ben Wilson
2023-06-24 20:20:41 -04:00
parent f61e9f1417
commit 9315d200ff
11 changed files with 199 additions and 62 deletions
+24 -5
View File
@@ -26,6 +26,7 @@ export class AppController {
const workers = await this.clientService.getByAddress(address);
const chartData = await this.clientStatisticsService.getChartDataForAddress(address);
return {
workersCount: workers.length,
@@ -35,27 +36,45 @@ export class AppController {
sessionId: worker.sessionId,
name: worker.clientName,
bestDifficulty: Math.floor(worker.bestDifficulty),
hashRate: Math.floor(await this.clientStatisticsService.getHashRate(worker.sessionId)),
hashRate: Math.floor(await this.clientStatisticsService.getHashRateForSession(worker.address, worker.clientName, worker.sessionId)),
startTime: worker.startTime
};
})
)
),
chartData
}
}
@Get('client/:address/:workerName')
async getWorkerGroupInfo(@Param('address') address: string, @Param('address') workerName: string) {
async getWorkerGroupInfo(@Param('address') address: string, @Param('workerName') workerName: string) {
const workers = await this.clientService.getByName(address, workerName);
const bestDifficulty = workers.reduce((pre, cur, idx, arr) => {
if (cur.bestDifficulty > pre) {
return cur.bestDifficulty;
}
return pre;
}, 0);
const chartData = await this.clientStatisticsService.getChartDataForGroup(address, workerName);
return {
name: workerName,
bestDifficulty: Math.floor(bestDifficulty),
chartData: chartData,
}
}
@Get('client/:address/:workerName/:sessionId')
async getWorkerInfo(@Param('address') address: string, @Param('workerName') workerName: string, @Param('sessionId') sessionId: string) {
const worker = await this.clientService.getById(address, workerName, sessionId);
const worker = await this.clientService.getBySessionId(address, workerName, sessionId);
if (worker == null) {
return new NotFoundException();
}
const chartData = await this.clientStatisticsService.getChartData(sessionId);
const chartData = await this.clientStatisticsService.getChartDataForSession(worker.address, worker.clientName, worker.sessionId);
return {
sessionId: worker.sessionId,