Blocks Mined data changed

This commit is contained in:
vijikannan 2019-07-29 11:31:50 +05:30
parent eddb90cf25
commit 3174184928
3 changed files with 102 additions and 63 deletions

View File

@ -1352,14 +1352,15 @@ export class BlockchainBlockController {
}
const BlockMineChartQuery = await getConnection()
.query(
"SELECT hash, date , total_edge_bits, cuckARoo29, cuckAToo31, ROUND(cuckARoo29 * 100.0 / total_edge_bits,2) as cuckARoo29per, ROUND(cuckAToo31 * 100.0 / total_edge_bits,2) as cuckAToo31per \
"SELECT hash, date , total_edge_bits, RandomX, Cuckoo, ProgPow, Round(RandomX * 100.0 / total_edge_bits,2) AS RandomXper, Round(Cuckoo * 100.0 / total_edge_bits,2) AS Cuckooper,Round(ProgPow * 100.0 / total_edge_bits,2) AS ProgPowper \
FROM (SELECT 1 as hash, \
date(DATE_TRUNC('day', timestamp at time zone '" +
process.env.TIME_ZONE +
"')) as date, \
COUNT(edge_bits) AS total_edge_bits, \
COUNT(CASE WHEN edge_bits = 29 THEN 1 ELSE NULL END) AS cuckARoo29, \
COUNT(CASE WHEN edge_bits = 31 THEN 1 ELSE NULL END) AS cuckAToo31 \
Count( CASE WHEN proof = 'RandomX' THEN 1 ELSE NULL END) AS RandomX, \
Count( CASE WHEN proof = 'Cuckoo' THEN 1 ELSE NULL END) AS Cuckoo,\
Count( CASE WHEN proof = 'ProgPow' THEN 1 ELSE NULL END) AS ProgPow \
FROM blockchain_block \
where " +
timeIntervalQry +
@ -1371,32 +1372,39 @@ export class BlockchainBlockController {
next(err_msg);
});
let date = [],
cuckARoo29per = [],
cuckAToo31per = [],
cuckARoo29Val = [],
cuckAToo31Val = [];
RandomXper = [],
Cuckooper = [],
ProgPowper = [],
RandomX = [],
Cuckoo = [],
ProgPow = [];
BlockMineChartQuery.forEach(e => {
console.log('e', e);
date.push(moment(e.date).format('YYYY-MM-DD'));
cuckARoo29per.push(parseFloat(e.cuckaroo29per));
cuckAToo31per.push(parseFloat(e.cuckatoo31per));
cuckARoo29Val.push(parseInt(e.cuckaroo29));
cuckAToo31Val.push(parseInt(e.cuckatoo31));
RandomXper.push(parseFloat(e.randomxper));
Cuckooper.push(parseFloat(e.cuckooper));
ProgPowper.push(parseFloat(e.progpowper));
RandomX.push(parseInt(e.randomx));
Cuckoo.push(parseInt(e.cuckoo));
ProgPow.push(parseInt(e.progpow));
});
response.status(200).json({
status: 200,
timestamp: Date.now(),
message: 'period of blocks generation per second fetched Successfully',
response: {
date,
cuckARoo29per,
cuckAToo31per,
cuckARoo29Val,
cuckAToo31Val,
RandomXper,
ProgPowper,
RandomX,
Cuckoo,
ProgPow,
},
});
} catch (error) {
next(new InternalServerErrorException(error));
}
};
};
}

View File

@ -85,6 +85,13 @@ export class BlockchainBlock {
})
EdgeBits: number;
@Column('character varying', {
nullable: false,
length: 64,
name: 'proof',
})
Proof: string;
@Column('int4', {
nullable: false,
array: true,

View File

@ -186,17 +186,23 @@ export class GraphListComponent implements OnInit {
res => {
if (res['status'] == 200) {
let mDate = res.response.date;
let mcuck29 = res.response.cuckARoo29per;
let mcuck31 = res.response.cuckAToo31per;
let mcuck29val = res.response.cuckARoo29Val;
let mcuck31val = res.response.cuckAToo31Val;
this.dg_last = mcuck29val[mcuck29val.length - 1];
let ProgPow = res.response.ProgPow;
let Cuckoo = res.response.Cuckoo;
let RandomX = res.response.RandomX;
let ProgPowper = res.response.ProgPowper;
let Cuckooper = res.response.Cuckooper;
let RandomXper = res.response.RandomXper;
this.dg_last = RandomXper[RandomXper.length - 1];
this.blockminedFunc(
mDate,
mcuck29,
mcuck31,
mcuck29val,
mcuck31val,
ProgPow,
Cuckoo,
RandomX,
ProgPowper,
Cuckooper,
RandomXper,
);
resolve();
}
@ -506,14 +512,14 @@ export class GraphListComponent implements OnInit {
};
}
blockminedFunc(mDate, mcuck29, mcuck31, mcuck29val, mcuck31val) {
blockminedFunc(mDate,ProgPow, Cuckoo, RandomX, ProgPowper, Cuckooper, RandomXper) {
this.doubleareaGraphData = {
data: [
{
x: mDate,
y: mcuck29,
text: mcuck29val,
hovertemplate: 'cuckARoo29 :%{y} % ( %{text:,} )',
y: Cuckooper,
text: Cuckoo,
hovertemplate: 'Cuckoo :%{y} % ( %{text:,} )',
name: '',
fill: 'tozeroy',
type: 'line',
@ -523,9 +529,9 @@ export class GraphListComponent implements OnInit {
},
{
x: mDate,
y: mcuck31,
text: mcuck31val,
hovertemplate: 'cuckAToo31 :%{y} % ( %{text:,} )',
y: RandomXper,
text: RandomX,
hovertemplate: 'RandomX :%{y} % ( %{text:,} )',
fill: 'tozeroy',
type: 'line',
name: '',
@ -533,6 +539,18 @@ export class GraphListComponent implements OnInit {
color: '#1ad5e9',
},
},
{
x: mDate,
y: ProgPowper,
text: ProgPow,
hovertemplate: 'ProgPow :%{y} % ( %{text:,} )',
fill: 'tozeroy',
type: 'line',
name: '',
line: {
color: '#f74f4f',
},
},
],
layout: {
hovermode: 'closest',
@ -542,9 +560,15 @@ export class GraphListComponent implements OnInit {
xaxis: {
tickformat: '%m-%d',
tickangle: -45,
rangemode: 'nonnegative',
fixedrange: true,
showgrid: true,
},
yaxis: {
title: 'Percentage(%)',
rangemode: 'nonnegative',
fixedrange: true,
showgrid: true,
},
margin: {
l: 50,