Block interval
This commit is contained in:
parent
ffec592e2e
commit
f2977b8823
@ -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 +
|
||||
"'";
|
||||
var IntervalDate = TotalDifficultyNBlockRequestData.Interval;
|
||||
}else {
|
||||
var timeIntervalQry =
|
||||
"timestamp at time zone '" +
|
||||
process.env.TIME_ZONE +
|
||||
"' > current_date - interval '1 day'";
|
||||
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) {
|
||||
|
@ -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",
|
||||
|
@ -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",
|
||||
|
@ -96,7 +96,7 @@
|
||||
</div> -->
|
||||
<epic-explorer-plotly *ngIf="hashdata.data" [data]="hashdata.data" [layout]="hashdata.layout">
|
||||
</epic-explorer-plotly>
|
||||
<div class="day_filter" *ngIf="this.title!='Transactions over time'">
|
||||
<div class="day_filter" *ngIf="this.title!='Transactions over time' && this.title!='Interval B/W Blocks'">
|
||||
|
||||
<a href="JavaScript:void(0);" *ngIf="this.title=='Total Difficulty' || this.title=='Target Difficulty' || this.title == 'Blocks'" (click)="
|
||||
ChartFromView('', '', '1 day', comp.Type); selectedItem = 6; comp.difficultyRange = '1 day';comp.TdifficultyRange = '1 day'
|
||||
@ -137,6 +137,19 @@
|
||||
[ngClass]="{ active: selectedItem8 == item3.id, day30_txt: true }">{{'home.OUTPUT' | translate}}</a>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="day_filter" *ngIf="this.title=='Interval B/W Blocks'">
|
||||
<a href="JavaScript:void(0);" (click)="
|
||||
ChartFromView('today'); selectedInteverval = 1
|
||||
" id="1" #intevalitem1 [ngClass]="{ active: selectedInteverval == intevalitem1.id, txt_primay: true }">Today</a>
|
||||
<a href="JavaScript:void(0);" (click)="
|
||||
ChartFromView('yesterday'); selectedInteverval = 2
|
||||
" id="2" #intevalitem2 [ngClass]="{ active: selectedInteverval == intevalitem2.id, txt_primay: true }">Yesterday</a>
|
||||
<a href="JavaScript:void(0);" (click)="ChartFromView('previous'); ">Pre</a>
|
||||
<span>{{showcurrentIntervalDate}}</span>
|
||||
<a href="JavaScript:void(0);" (click)="ChartFromView('next'); ">Next</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@ -163,6 +176,8 @@
|
||||
routerLink="/chart/transactions-over-time">{{'home.TRANSACTIONS_BY_TIME' | translate}}</a></li>
|
||||
<li class="mb-1" *ngIf="this.title!='Blocks'"><a
|
||||
routerLink="/chart/blocks">{{'home.BLOCKS' | translate}}</a></li>
|
||||
<li class="mb-1" *ngIf="this.title!='Interval B/W Blocks'"><a
|
||||
routerLink="/chart/interval-between-blocks">{{'home.BLOCKSINTERVAL' | translate}}</a></li>
|
||||
<li class="mb-1" *ngIf="this.title!='Blocks Mined'"><a
|
||||
routerLink="/chart/blocks-mined">{{'home.BLOCKS_MINED' | translate}}</a></li>
|
||||
<li class="mb-1" *ngIf="this.title!='Transaction Fees'"><a
|
||||
|
@ -27,6 +27,9 @@ export class GraphDetailComponent implements OnInit {
|
||||
public Type: any = '';
|
||||
public selectedTarget: Number = 3;
|
||||
public selectedTarget12: Number = 1;
|
||||
public selectedInteverval: Number = 1;
|
||||
public currenyIntervalDate: any;
|
||||
public showcurrentIntervalDate: any;
|
||||
|
||||
public GraphtInput: any;
|
||||
public GraphtOutput: any;
|
||||
@ -119,6 +122,19 @@ export class GraphDetailComponent implements OnInit {
|
||||
);
|
||||
});
|
||||
break;
|
||||
case 'interval-between-blocks':
|
||||
this.comp.Blockintervalreq().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';
|
||||
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;
|
||||
|
@ -371,6 +371,50 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div *ngIf="viewchartvar" [ngClass]="{'col-md-6 col-lg-4 mb-4' : true, 'd-none' : viewchart}">
|
||||
<div class="box_shadow">
|
||||
<div class="blocks">
|
||||
<h2 class="chart_heading d-inline-block">{{'home.BLOCKSINTERVAL' | translate}}</h2>
|
||||
<span class="txn_count" *ngIf="this.blockinteval_last">{{
|
||||
this.blockinteval_last | number
|
||||
}}</span>
|
||||
<div class="chart_show">
|
||||
<epic-explorer-plotly *ngIf="barGraphIntevalData.data" [data]="barGraphIntevalData.data" [layout]="barGraphIntevalData.layout"></epic-explorer-plotly>
|
||||
<div *ngIf="!barGraphIntevalData.data" class="feedback_div news_desc text-center">
|
||||
<div class="graph_img background_loading mx-auto mb-3"></div>
|
||||
<div class=" p-3 bg-white">
|
||||
<p class="mb-2 background_loading para_load"></p>
|
||||
<p class="mb-2 background_loading para_load"></p>
|
||||
<p class="mb-2 background_loading para_load"></p>
|
||||
<p class="mb-2 background_loading para_load"></p>
|
||||
<p class="mb-2 background_loading para_load"></p>
|
||||
<p class="mb-2 background_loading para_load"></p>
|
||||
<p class="mb-2 background_loading para_load"></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="day_filter">
|
||||
<a href="JavaScript:void(0);" (click)="
|
||||
Blockintervalreq('today'); selectedInteverval = 1
|
||||
" id="1" #intevalitem1 [ngClass]="{ active: selectedInteverval == intevalitem1.id, txt_primay: true }">Today</a>
|
||||
<a href="JavaScript:void(0);" (click)="
|
||||
Blockintervalreq('yesterday'); selectedInteverval = 2
|
||||
" id="2" #intevalitem2 [ngClass]="{ active: selectedInteverval == intevalitem2.id, txt_primay: true }">Yesterday</a>
|
||||
<a href="JavaScript:void(0);" (click)="Blockintervalreq('previous'); ">Pre</a>
|
||||
<span>{{showcurrentIntervalDate}}</span>
|
||||
<a href="JavaScript:void(0);" (click)="Blockintervalreq('next'); ">Next</a>
|
||||
|
||||
</div>
|
||||
<div class="explore_all text-right">
|
||||
<a routerLink="/chart/interval-between-blocks"><span class="text-uppercase d-block">{{'home.EXPLORE_IT' | translate}} <i class="fa fa-long-arrow-right"></i></span></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div *ngIf="viewchartvar" [ngClass]="{'col-md-6 col-lg-4 mb-4' : true, 'd-none' : viewchart}">
|
||||
<div class="box_shadow">
|
||||
<div class="blocks">
|
||||
|
@ -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}<br> 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 = {
|
||||
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user