diff --git a/server/controllers/BlockchainBlock.ts b/server/controllers/BlockchainBlock.ts index 9105136..2624244 100644 --- a/server/controllers/BlockchainBlock.ts +++ b/server/controllers/BlockchainBlock.ts @@ -304,16 +304,8 @@ export class BlockchainBlockController { * produces: * - application/json * parameters: - * - name: FromDate - * description: Enter the From date - * in: query - * type: string - * - name: ToDate - * description: Enter the To date - * in: query - * type: string * - name: Interval - * description: Try to give Intevals such as 1 week/ 15 days/ 30 days/ 60 days/ 3 months + * description: try to get Date * in: query * type: string * responses: @@ -1202,71 +1194,37 @@ export class BlockchainBlockController { const TotalDifficultyNBlockRequestData: TotalDifficultyNBlockDto = request.query; if (TotalDifficultyNBlockRequestData.Interval) { - var timeIntervalQry = - "timestamp at time zone '" + - process.env.TIME_ZONE + - "' > current_date - interval '" + - TotalDifficultyNBlockRequestData.Interval + - "'"; - } else if ( - TotalDifficultyNBlockRequestData.FromDate || - TotalDifficultyNBlockRequestData.ToDate - ) { - let fromdate = moment(TotalDifficultyNBlockRequestData.FromDate) - .utc() - .format('YYYY-MM-DD'); - let todate = moment(TotalDifficultyNBlockRequestData.ToDate) - .utc() - .format('YYYY-MM-DD'); - - var timeIntervalQry = - "timestamp at time zone '" + - process.env.TIME_ZONE + - "' BETWEEN SYMMETRIC '" + - fromdate + - "' AND '" + - todate + - "'"; - } else { - var timeIntervalQry = - "timestamp at time zone '" + - process.env.TIME_ZONE + - "' > current_date - interval '1 day'"; - } + var IntervalDate = TotalDifficultyNBlockRequestData.Interval; + }else { + var current_date = Date.now(); + var IntervalDate = ""; + IntervalDate = moment(current_date).format('YYYY-MM-DD'); + } const BlockQuery = await getConnection(Global.network) .query( - "select 1 as hash, max(total_difficulty_cuckaroo) as total_difficulty_cuckaroo, \ - max(total_difficulty_cuckatoo) as total_difficulty_cuckatoo, \ - max(total_difficulty_progpow) as total_difficulty_progpow, \ - max(total_difficulty_randomx) as total_difficulty_randomx, date(DATE_TRUNC('day', timestamp at time zone '" + - process.env.TIME_ZONE + - "')) as date, count(hash) as blocks \ - from blockchain_block where " + - timeIntervalQry + - "group by DATE_TRUNC('day', timestamp at time zone '" + - process.env.TIME_ZONE + - "') order by date", + "SELECT bb.height, coalesce(max(bb.alter), 0) as alter, bb.timestamp FROM (SELECT height, EXTRACT(EPOCH FROM (timestamp - LAG(timestamp) OVER (ORDER BY timestamp))) AS alter, timestamp FROM blockchain_block where timestamp::date = date '"+IntervalDate+"' order by height asc) as bb group by bb.height , bb.timestamp;", ) .catch(err_msg => { next(err_msg); }); let date = [], - blockDate = [], + alter = [], blocks = []; BlockQuery.forEach(e => { - blockDate.push(moment(e.date).format('YYYY-MM-DD')); - blocks.push(parseInt(e.blocks)); + //date.push(moment(e.timestamp).format('YYYY-MM-DD HH:MM:SS')); + alter.push(parseInt(e.alter)); + blocks.push(parseInt(e.height)); }); response.status(200).json({ status: 200, timestamp: Date.now(), message: 'Block Interval Data fetched Successfully', response: { - Date: date, + //Date: date, Blocks: blocks, - blockDate:blockDate + alter:alter }, }); } catch (error) { diff --git a/server/i18n/de.json b/server/i18n/de.json index 6044647..7afb9bc 100644 --- a/server/i18n/de.json +++ b/server/i18n/de.json @@ -43,6 +43,7 @@ "TARGET_DIFFICULTY" : "Zielschwierigkeit", "TRANSACTIONS_BY_TIME" : "Transaktionen im Zeitverlauf", "BLOCKS" : "Blöcke", + "BLOCKSINTERVAL" : "Intervall-S / W-Blöcke", "BLOCK" : "Block", "BLOCKS_MINED" : "Blöcke abgebaut", "TRANSACTION_FEES" : "Transkationsgebühren", diff --git a/server/i18n/en.json b/server/i18n/en.json index b9f73e5..198f206 100644 --- a/server/i18n/en.json +++ b/server/i18n/en.json @@ -43,6 +43,7 @@ "TARGET_DIFFICULTY" : "Target Difficulty", "TRANSACTIONS_BY_TIME" : "Transactions over time", "BLOCKS" : "Blocks", + "BLOCKSINTERVAL" : "Interval B/W Blocks", "BLOCK" : "Block", "BLOCKS_MINED" : "Blocks Mined", "TRANSACTION_FEES" : "Transaction Fees", diff --git a/src/app/view/graph-view/graph-detail/graph-detail.component.html b/src/app/view/graph-view/graph-detail/graph-detail.component.html index 9b59282..2ef38dc 100644 --- a/src/app/view/graph-view/graph-detail/graph-detail.component.html +++ b/src/app/view/graph-view/graph-detail/graph-detail.component.html @@ -96,7 +96,7 @@ --> -
+
{{'home.OUTPUT' | translate}}
+ +
+ Today + Yesterday + Pre + {{showcurrentIntervalDate}} + Next +
+
@@ -163,6 +176,8 @@ routerLink="/chart/transactions-over-time">{{'home.TRANSACTIONS_BY_TIME' | translate}}
  • {{'home.BLOCKS' | translate}}
  • +
  • {{'home.BLOCKSINTERVAL' | translate}}
  • {{'home.BLOCKS_MINED' | translate}}
  • { + this.hashdata = this.comp.barGraphIntevalData; + this.currenyIntervalDate = this.comp.currenyIntervalDate; + this.showcurrentIntervalDate =this.comp.showcurrentIntervalDate; + this.hashdata.layout.height = 300; + this.title = 'Interval B/W Blocks'; + this.selectedInteverval = 1; + this.titleService.setTitle( + this.route.snapshot.data.title + ' - ' + this.title, + ); + }); + break; case 'transaction-fees': this.comp.Transcationreq().then(res => { this.hashdata = this.comp.transcationGraphData; @@ -257,6 +273,15 @@ export class GraphDetailComponent implements OnInit { this.title = 'Blocks'; }); break; + case 'interval-between-blocks': + this.comp.Blockintervalreq(p1).then(res => { + this.hashdata = this.comp.barGraphIntevalData; + this.currenyIntervalDate = this.comp.currenyIntervalDate; + this.showcurrentIntervalDate =this.comp.showcurrentIntervalDate; + this.hashdata.layout.height = 300; + this.title = 'Interval B/W Blocks'; + }); + break; case 'blocks-mined': this.comp.Blockminedreq(p1, p2, p3).then(res => { this.hashdata = this.comp.doubleareaGraphData; 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 ebd9d13..c934843 100644 --- a/src/app/view/home/graph-list/graph-list.component.html +++ b/src/app/view/home/graph-list/graph-list.component.html @@ -371,6 +371,50 @@ + + + +
    + +
    +
    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 166fc85..fafde54 100644 --- a/src/app/view/home/graph-list/graph-list.component.ts +++ b/src/app/view/home/graph-list/graph-list.component.ts @@ -3,6 +3,7 @@ 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'; +import * as moment from 'moment'; @Component({ selector: 'epic-explorer-graph-list', @@ -16,6 +17,7 @@ export class GraphListComponent implements OnInit { public areaGraphData: any = []; public doubleareaGraphData: any = []; public barGraphData: any = []; + public barGraphIntevalData: any = []; public blockGraphData: any = []; public bubbleGraphdData: any = []; public feeGraphData: any = []; @@ -25,6 +27,8 @@ export class GraphListComponent implements OnInit { public stackGraphData: any = []; public pieGraphData: any = []; public linearTotalGraphData: any = []; + public currenyIntervalDate: any; + public showcurrentIntervalDate: any; public lg_last: any; public ag_last: any = ''; @@ -38,6 +42,7 @@ export class GraphListComponent implements OnInit { public hg_last: any = ''; public sg_last: any = ''; public pg_last: any = ''; + public blockinteval_last: any = ''; public selectedItem: Number = 6; public selectedItem3: Number = 1; @@ -53,6 +58,7 @@ export class GraphListComponent implements OnInit { public selectedItem12: Number = 4; public selectedTarget: Number = 6; public selectedTarget12: Number = 4; + public selectedInteverval: Number = 1; public tInput: any; public tOutput: any; @@ -80,6 +86,8 @@ export class GraphListComponent implements OnInit { this.Difficultyreq('total'); this.blockreq(); + this.Blockintervalreq(); + /* Transcation fee chart fetching */ this.Transcationreq(); @@ -497,6 +505,49 @@ export class GraphListComponent implements OnInit { }); } + Blockintervalreq(interval = ''){ + //interval = '2019-08-11'; + if(interval == "today"){ + this.currenyIntervalDate = moment(new Date()).format('YYYY-MM-DD'); + this.showcurrentIntervalDate = moment(new Date()).format('MM-DD-YYYY'); + }else if(interval == "yesterday"){ + this.currenyIntervalDate = moment(new Date()).subtract(1, "days").format("YYYY-MM-DD"); + this.showcurrentIntervalDate = moment(new Date()).subtract(1, "days").format("MM-DD-YYYY"); + }else if(interval == "previous"){ + var currentdate = this.currenyIntervalDate; + this.currenyIntervalDate = moment(currentdate).subtract(1, "days").format("YYYY-MM-DD"); + this.showcurrentIntervalDate = moment(currentdate).subtract(1, "days").format("MM-DD-YYYY"); + }else if(interval == "next"){ + var currentdate = this.currenyIntervalDate; + this.currenyIntervalDate = moment(currentdate).add(1, "days").format("YYYY-MM-DD"); + this.showcurrentIntervalDate = moment(currentdate).add(1, "days").format("MM-DD-YYYY"); + }else{ + this.currenyIntervalDate = moment(new Date()).format('YYYY-MM-DD'); + this.showcurrentIntervalDate = moment(new Date()).format('MM-DD-YYYY'); + } + // console.log(this.currenyIntervalDate); + // console.log(this.showcurrentIntervalDate); + interval = this.currenyIntervalDate; + return new Promise((resolve, reject) => { + let params = new HttpParams(); + params = params.append('Interval', interval); + this.chartService + .apiGetRequest(params, '/blockchain_block/blockinterval') + .subscribe( + res => { + if (res['status'] == 200) { + let BlocksChartHeight = res.response.height; + let Blockval = res.response.alter; + this.blockinteval_last = Blockval[Blockval.length - 1]; + this.BlocksIntevalFunc(BlocksChartHeight, Blockval); + resolve(); + } + }, + error => { }, + ); + }); + } + blockreq( fromDate = '', ToDate = '', @@ -535,7 +586,7 @@ export class GraphListComponent implements OnInit { autosize: true, showlegend: true, legend: {"orientation": "h", - x: 0.35, y: -0.5,font :{ 'size': 10}}, + x: 0.1, y: -0.5,font :{ 'size': 10}}, xaxis: { tickangle: -45, tickformat: tickformat, @@ -704,6 +755,49 @@ export class GraphListComponent implements OnInit { }; } + BlocksIntevalFunc(BlocksChartHeight, Blockval) { + this.barGraphIntevalData = { + data: [ + { + x: BlocksChartHeight, + y: Blockval, + text: Blockval, + name: '', + hovertemplate: 'Blocks %{x}
    Inteval : %{text:,}', + type: 'bar', + marker: { + color: Blockval, + colorscale: 'Viridis', + }, + }, + ], + layout: { + hovermode: 'closest', + height: 250, + autosize: true, + showlegend: false, + xaxis: { + tickangle: -45, + showgrid: true, + title: 'Blocks Height', + fixedrange: true + }, + yaxis: { + title: 'Seonds', + showgrid: true, + fixedrange: true + }, + margin: { + l: 50, + r: 50, + b: 50, + t: 50, + }, + }, + options: null, + }; + } + totalBlocksFunc(DifficultychartDate, Blockval) { this.barGraphData = { @@ -803,7 +897,7 @@ export class GraphListComponent implements OnInit { }, text: gReward, hovertemplate: - '%{x}
    supply per day: %{text:,}
    Total supply: %{y:,}', + '%{x}
    supply per day : %{text:,}
    Total supply : %{y:,}', }, ], layout: { @@ -890,7 +984,7 @@ export class GraphListComponent implements OnInit { x: mDate, y: Cuckooper, text: Cuckoo, - hovertemplate: 'Cuckoo :%{y} % ( %{text:,} )', + hovertemplate: 'Cuckoo : %{y} % ( %{text:,} )', hoverlabel: {namelength : 0}, name: 'Cuckoo', fill: 'tozeroy', @@ -915,7 +1009,7 @@ export class GraphListComponent implements OnInit { x: mDate, y: RandomXper, text: RandomX, - hovertemplate: 'RandomX :%{y} % ( %{text:,} )', + hovertemplate: 'RandomX : %{y} % ( %{text:,} )', hoverlabel: {namelength : 0}, fill: 'tozeroy', type: 'line', @@ -928,7 +1022,7 @@ export class GraphListComponent implements OnInit { x: mDate, y: ProgPowper, text: ProgPow, - hovertemplate: 'ProgPow :%{y} % ( %{text:,} )', + hovertemplate: 'ProgPow : %{y} % ( %{text:,} )', hoverlabel: {namelength : 0}, fill: 'tozeroy', type: 'line', @@ -1093,7 +1187,7 @@ export class GraphListComponent implements OnInit { }, showlegend: true, legend: {"orientation": "h", - x: 0.35, y: -0.5,font :{ 'size': 10}} + x: 0.05, y: -0.5,font :{ 'size': 10}} }, options: null, }; @@ -1158,7 +1252,7 @@ export class GraphListComponent implements OnInit { autosize: true, showlegend: true, legend: {"orientation": "h", - x: 0.35, y: -0.5,font :{ 'size': 10}}, + x: 0.1, y: -0.5,font :{ 'size': 10}}, xaxis: { tickangle: -45, tickformat: tickformat,