From 57ca6aafe8072e7119256ee5a4ee5a33da01b448 Mon Sep 17 00:00:00 2001 From: SuriyaR Date: Wed, 31 Jul 2019 19:43:06 +0530 Subject: [PATCH] Api changes --- server/controllers/BlockchainBlock.ts | 23 ++++++++-- .../block-detail/block-detail.component.html | 4 +- .../home/graph-list/graph-list.component.html | 46 +++++++++++++++++-- .../home/graph-list/graph-list.component.ts | 22 +++++++-- src/app/view/home/home-worksapce.component.ts | 13 ++++-- .../latestblocks/latestblocks.component.html | 3 +- 6 files changed, 96 insertions(+), 15 deletions(-) diff --git a/server/controllers/BlockchainBlock.ts b/server/controllers/BlockchainBlock.ts index 29215df..900303b 100644 --- a/server/controllers/BlockchainBlock.ts +++ b/server/controllers/BlockchainBlock.ts @@ -1009,7 +1009,7 @@ export class BlockchainBlockController { process.env.TIME_ZONE + "' > current_date - interval '30 days'"; } - const TotalDifficultyNBlockQuery = await getConnection() + const BlockQuery = await getConnection() .query( "select 1 as hash, max(total_difficulty_cuckaroo) as total_difficulty_cuckaroo, \ max(total_difficulty_cuckatoo) as total_difficulty_cuckatoo, \ @@ -1026,18 +1026,35 @@ export class BlockchainBlockController { .catch(err_msg => { next(err_msg); }); + const TotalDifficultyNBlockQuery = await getConnection() + .query( + "select 1 as hash, total_difficulty_cuckaroo as total_difficulty_cuckaroo, \ + total_difficulty_cuckatoo as total_difficulty_cuckatoo, \ + total_difficulty_progpow as total_difficulty_progpow, \ + total_difficulty_randomx as total_difficulty_randomx, date(DATE_TRUNC('day', timestamp at time zone '" + + process.env.TIME_ZONE + + "')) as date \ + from blockchain_block where " + + timeIntervalQry + + " order by date", + ) + .catch(err_msg => { + next(err_msg); + }); let date = [], DifficultyCuckaroo = [], DifficultyCuckatoo = [], DifficultyProgpow = [], DifficultyRandomx = [], blocks = []; - TotalDifficultyNBlockQuery.forEach(e => { - date.push(moment(e.date).format('YYYY-MM-DD')); + TotalDifficultyNBlockQuery.forEach(e => { DifficultyCuckaroo.push(parseInt(e.total_difficulty_cuckaroo)); DifficultyCuckatoo.push(parseInt(e.total_difficulty_cuckatoo)); DifficultyProgpow.push(parseInt(e.total_difficulty_progpow)); DifficultyRandomx.push(parseInt(e.total_difficulty_randomx)); + }); + BlockQuery.forEach(e => { + date.indexOf(moment(e.date).format('YYYY-MM-DD')) < 0 ? date.push(moment(e.date).format('YYYY-MM-DD')) : '' blocks.push(parseInt(e.blocks)); }); response.status(200).json({ diff --git a/src/app/view/block-view/block-detail/block-detail.component.html b/src/app/view/block-view/block-detail/block-detail.component.html index 0a8e078..48c1434 100644 --- a/src/app/view/block-view/block-detail/block-detail.component.html +++ b/src/app/view/block-view/block-detail/block-detail.component.html @@ -70,7 +70,7 @@
{{'home.DIFFICULTY' | translate}}
-
Cuckaroo : {{ hashdata.BlockchainBlockFetchQuery.TotalDifficultyCuckaroo }} | Cuckatoo : {{ hashdata.BlockchainBlockFetchQuery.TotalDifficultyCuckatoo }}
Progpow : {{ hashdata.BlockchainBlockFetchQuery.TotalDifficultyProgpow }} | Randomx : {{ hashdata.BlockchainBlockFetchQuery.TotalDifficultyRandomx }}
+
{{(hashdata.BlockchainBlockFetchQuery.Proof == 'Cuckoo') ? ((hashvalue.target_difficulty_cuckatoo + hashvalue.target_difficulty_cuckaroo) | number) : (hashdata.BlockchainBlockFetchQuery.Proof == 'RandomX') ? (hashvalue.target_difficulty_randomx | number) : (hashdata.BlockchainBlockFetchQuery.Proof == 'ProgPow') ? (hashvalue.target_difficulty_progpow | number) : 0}}
@@ -96,7 +96,7 @@
{{'home.ALGORITHM' | translate}} -
{{ hashdata.BlockchainBlockFetchQuery.PoWAlgorithm }}
+
{{ hashdata.BlockchainBlockFetchQuery.Proof }}
diff --git a/src/app/view/home/graph-list/graph-list.component.html b/src/app/view/home/graph-list/graph-list.component.html index 5307929..06ece95 100644 --- a/src/app/view/home/graph-list/graph-list.component.html +++ b/src/app/view/home/graph-list/graph-list.component.html @@ -261,7 +261,47 @@ -
+
+

Blocks by Algorithm

@@ -308,7 +348,7 @@
-
+

{{'home.BLOCK_INTERVAL' | translate}}

@@ -349,7 +389,7 @@
-
+

{{'home.TRANSACTIONS_VS_DATE' | translate}}

diff --git a/src/app/view/home/graph-list/graph-list.component.ts b/src/app/view/home/graph-list/graph-list.component.ts index 89df62a..dfb0005 100644 --- a/src/app/view/home/graph-list/graph-list.component.ts +++ b/src/app/view/home/graph-list/graph-list.component.ts @@ -2,6 +2,7 @@ import { Component, OnInit, Input } from '@angular/core'; import { ChartService } from '../../../shared/services/chart.service'; import { HttpClient, HttpParams } from '@angular/common/http'; import { TransServiceService } from '../../../shared/services/trans-service.service'; +import { Router } from '@angular/router'; @Component({ selector: 'epic-explorer-graph-list', @@ -54,7 +55,16 @@ export class GraphListComponent implements OnInit { public tDate: any; public tHour: any; - constructor(private chartService: ChartService, private http: HttpClient,public translate: TransServiceService) {} + viewchartvar: boolean; + + constructor(private chartService: ChartService, private http: HttpClient,public translate: TransServiceService, private router: Router, + ) { + if (this.router.url == '/all') { + this.viewchartvar = true; + } else { + this.viewchartvar = false; + } + } ngOnInit() { /* Total Difficulty and blocks chart fetching */ @@ -79,7 +89,7 @@ export class GraphListComponent implements OnInit { this.Transactionlinechartreq(); /* Transaction2line chart fetching */ - this.Transactiondoublelinechartreq(); + // this.Transactiondoublelinechartreq(); /* Stack chart fetching */ this.stackchartreq(); @@ -722,13 +732,19 @@ export class GraphListComponent implements OnInit { hovermode: 'closest', // width: 350, height: 250, - autosize: false, + autosize: true, xaxis: { tickformat: '%m-%d', tickangle: -45, + rangemode: 'nonnegative', + fixedrange: true, + showgrid: true, }, yaxis: { title: 'Block / sec', + rangemode: 'nonnegative', + fixedrange: true, + showgrid: true, }, margin: { l: 50, diff --git a/src/app/view/home/home-worksapce.component.ts b/src/app/view/home/home-worksapce.component.ts index ecba16b..98f69aa 100644 --- a/src/app/view/home/home-worksapce.component.ts +++ b/src/app/view/home/home-worksapce.component.ts @@ -1,6 +1,7 @@ import { Component, OnInit, Inject, AfterViewInit } from '@angular/core'; import { DOCUMENT } from '@angular/common'; import { Utils } from 'src/app/shared/utils'; +import { Router } from '@angular/router'; @Component({ selector: 'epic-explorer-home-worksapce', @@ -16,7 +17,7 @@ import { Utils } from 'src/app/shared/utils';
-
Difficulty
{{ hashvalue.target_difficulty_cuckaroo | number }}, {{ hashvalue.target_difficulty_cuckatoo | number }}, {{ hashvalue.target_difficulty_progpow | number }}, {{ hashvalue.target_difficulty_randomx | number }}
+ +
Difficulty
{{(hashvalue.powalgo == 'Cuckoo') ? ((hashvalue.target_difficulty_cuckatoo + hashvalue.target_difficulty_cuckaroo) | number) : (hashvalue.powalgo == 'RandomX') ? (hashvalue.target_difficulty_randomx | number) : (hashvalue.powalgo == 'ProgPow') ? (hashvalue.target_difficulty_progpow | number) : 0}}
Pow Algo
{{ hashvalue.powalgo }}