From 1fed34cf0ab4e581cd2634247917459dc2833ced Mon Sep 17 00:00:00 2001 From: Felix Brucker Date: Thu, 27 Jun 2024 20:27:00 +0700 Subject: [PATCH] Add farm time to account won blocks --- src/app/api/types/account/account-won-block.ts | 1 + .../farmer-won-blocks.component.html | 9 ++++++--- .../farmer-won-blocks.component.ts | 18 ++++++++++++++++++ 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/app/api/types/account/account-won-block.ts b/src/app/api/types/account/account-won-block.ts index 5fbbfb4..1fd4239 100644 --- a/src/app/api/types/account/account-won-block.ts +++ b/src/app/api/types/account/account-won-block.ts @@ -24,6 +24,7 @@ export interface AccountWonBlock { createdAt: string remarks: Remark[] historicalRate?: HistoricalRate + farmTimeInSeconds?: number } diff --git a/src/app/farmer-won-blocks/farmer-won-blocks.component.html b/src/app/farmer-won-blocks/farmer-won-blocks.component.html index 2bc3e76..cbcaa05 100644 --- a/src/app/farmer-won-blocks/farmer-won-blocks.component.html +++ b/src/app/farmer-won-blocks/farmer-won-blocks.component.html @@ -32,18 +32,19 @@ {{snippetService.getSnippet('blocks-won-component.header.height')}} {{snippetService.getSnippet('blocks-won-component.header.effort')}} - Farmer Reward + Farmer Reward + Farm Time Remarks - + - + @@ -57,6 +58,8 @@ {{getFarmerRewardFormatted(block)}} + N/A + {{formatFarmTime(block.farmTimeInSeconds)}} sec OK diff --git a/src/app/farmer-won-blocks/farmer-won-blocks.component.ts b/src/app/farmer-won-blocks/farmer-won-blocks.component.ts index 298ad00..a7136c3 100644 --- a/src/app/farmer-won-blocks/farmer-won-blocks.component.ts +++ b/src/app/farmer-won-blocks/farmer-won-blocks.component.ts @@ -285,6 +285,24 @@ export class FarmerWonBlocksComponent implements OnInit, OnDestroy { })) } + public getFarmTimeColor(farmTimeInSeconds: number): string { + if (farmTimeInSeconds < 9) { + return '#46cf76' + } + if (farmTimeInSeconds < 17) { + return '#b9a44c' + } + if (farmTimeInSeconds < 25) { + return '#ffaa00' + } + + return '#ff4d4d' + } + + public formatFarmTime(farmTimeInSeconds: number): number { + return (new BigNumber(farmTimeInSeconds)).decimalPlaces(3).toNumber() + } + private makeChartUpdateOptions(wonBlocks: AccountWonBlock[]): EChartsOption { const wonBlocksWithEffort = wonBlocks.filter(wonBlock => wonBlock.effort !== null)