Skip to content

Commit

Permalink
Add farm time to account won blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
felixbrucker committed Jun 27, 2024
1 parent 486076e commit 1fed34c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/app/api/types/account/account-won-block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export interface AccountWonBlock {
createdAt: string
remarks: Remark[]
historicalRate?: HistoricalRate
farmTimeInSeconds?: number
}


9 changes: 6 additions & 3 deletions src/app/farmer-won-blocks/farmer-won-blocks.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,19 @@
</th>
<th scope="col">{{snippetService.getSnippet('blocks-won-component.header.height')}}</th>
<th scope="col">{{snippetService.getSnippet('blocks-won-component.header.effort')}}</th>
<th>Farmer Reward</th>
<th scope="col">Farmer Reward</th>
<th scope="col"><span ngbTooltip="The time it took your farm from receiving the signage point till a block was created">Farm Time</span></th>
<th scope="col">Remarks</th>
</tr>
</thead>
<tbody>
<tr *ngIf="isLoading && (hasWonBlocksObservable | async) === false">
<td colspan="5" style="text-align: center">
<td colspan="6" style="text-align: center">
<app-loading-state></app-loading-state>
</td>
</tr>
<tr *ngIf="!isLoading && (hasWonBlocksObservable | async) === false">
<td colspan="5" style="text-align: center; padding-top: 1rem">
<td colspan="6" style="text-align: center; padding-top: 1rem">
<app-empty-state [text]="snippetService.getSnippet('blocks-won-component.no-blocks-won-yet')" [icon]="faCubes"></app-empty-state>
</td>
</tr>
Expand All @@ -57,6 +58,8 @@
{{getFarmerRewardFormatted(block)}}
</span>
</td>
<td *ngIf="block.farmTimeInSeconds === undefined">N/A</td>
<td *ngIf="block.farmTimeInSeconds !== undefined"><span [ngStyle]="{color: getFarmTimeColor(block.farmTimeInSeconds)}">{{formatFarmTime(block.farmTimeInSeconds)}} sec</span></td>
<td *ngIf="block.remarks === undefined || block.remarks.length === 0">
<span class="badge remark-pill background-color-light-green">OK</span>
</td>
Expand Down
18 changes: 18 additions & 0 deletions src/app/farmer-won-blocks/farmer-won-blocks.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 1fed34c

Please sign in to comment.