This commit is contained in:
SuriyaR 2019-08-06 18:40:10 +05:30
parent 79f5223683
commit d410ca2ca5
7 changed files with 193 additions and 58 deletions

View File

@ -192,7 +192,7 @@ export class BlockchainBlockController {
/**
* @swagger
* /epic_explorer/v1/blockchain_block/totaldiffnblock:
* /epic_explorer/v1/blockchain_block/totaldiff:
* get:
* tags:
* - name: BLOCKCHAIN_BLOCK | BLOCKCHAIN_BLOCK CONTROLLER
@ -217,16 +217,51 @@ export class BlockchainBlockController {
* type: string
* responses:
* 200:
* description: Total Difficulty and No. of blocks fetched successfully
* description: Total Difficulty fetched successfully
*/
this.router.get(
`${this.path}/totaldiffnblock`,
`${this.path}/totaldiff`,
validationMiddleware(TotalDifficultyNBlockDto, true),
this.TotalDifficultyNBlock,
);
/**
* @swagger
* /epic_explorer/v1/blockchain_block/blockcount:
* get:
* tags:
* - name: BLOCKCHAIN_BLOCK | BLOCKCHAIN_BLOCK CONTROLLER
* description: To get Total Difficulty and Number of Blocks
* summary: To get Total Difficulty and Number of Blocks
* consumes:
* - application/json
* 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
* in: query
* type: string
* responses:
* 200:
* description: Total Difficulty fetched successfully
*/
this.router.get(
`${this.path}/blockcount`,
validationMiddleware(TotalDifficultyNBlockDto, true),
this.BlockCount,
);
/**
* @swagger
* /epic_explorer/v1/blockchain_block/stackblock:
* get:
* tags:
@ -971,7 +1006,7 @@ export class BlockchainBlockController {
}
};
private TotalDifficultyNBlock = async (
private BlockCount = async (
request: Request,
response: Response,
next: NextFunction,
@ -1028,36 +1063,11 @@ 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 = [],
blockDate = [],
DifficultyCuckaroo = [],
DifficultyCuckatoo = [],
DifficultyProgpow = [],
DifficultyRandomx = [],
blocks = [];
TotalDifficultyNBlockQuery.forEach(e => {
//date.indexOf(moment(e.date).format('YYYY-MM-DD')) < 0 ?
date.push(moment(e.date).format('YYYY-MM-DD'));
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 => {
blockDate.push(moment(e.date).format('YYYY-MM-DD'));
blocks.push(parseInt(e.blocks));
@ -1069,7 +1079,100 @@ export class BlockchainBlockController {
response: {
Date: date,
Blocks: blocks,
blockDate:blockDate,
blockDate:blockDate
},
});
} catch (error) {
next(new InternalServerErrorException(error));
}
};
private TotalDifficultyNBlock = async (
request: Request,
response: Response,
next: NextFunction,
) => {
try {
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'";
}
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_TRUNC('minute', timestamp at time zone '" +
process.env.TIME_ZONE +
"') as date \
from blockchain_block where " +
timeIntervalQry +
" order by date",
)
.catch(err_msg => {
next(err_msg);
});
console.log( "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_TRUNC('minute', timestamp at time zone '" +
process.env.TIME_ZONE +
"') as date \
from blockchain_block where " +
timeIntervalQry +
" order by date");
let date = [],
DifficultyCuckaroo = [],
DifficultyCuckatoo = [],
DifficultyProgpow = [],
DifficultyRandomx = [];
TotalDifficultyNBlockQuery.forEach(e => {
//date.indexOf(moment(e.date).format('YYYY-MM-DD')) < 0 ?
date.push(moment(e.date).format('YYYY-MM-DD'));
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));
});
response.status(200).json({
status: 200,
timestamp: Date.now(),
message: 'Total Difficulty and Blocks Data fetched Successfully',
response: {
Date: date,
DifficultyCuckaroo: DifficultyCuckaroo,
DifficultyCuckatoo: DifficultyCuckatoo,
DifficultyProgpow: DifficultyProgpow,

View File

@ -68,7 +68,7 @@
<img src="assets/img/difficulty.png" height="60" />
</div>
<div class="d-inline-block align-middle ml-2">
<span class="">{{'home.DIFFICULTY' | translate}}</span>
<span class="">Target Difficulty</span>
<h6 class="view_txt">{{(hashdata.BlockchainBlockFetchQuery.Proof == 'Cuckoo') ? (hashdata.BlockchainBlockFetchQuery.TotalCuckoo | number) : (hashdata.BlockchainBlockFetchQuery.Proof == 'RandomX') ? (hashdata.BlockchainBlockFetchQuery.TotalDifficultyRandomx | number) : (hashdata.BlockchainBlockFetchQuery.Proof == 'ProgPow') ? (hashdata.BlockchainBlockFetchQuery.TotalDifficultyProgpow | number) : 0}}</h6>
</div>
</div>

View File

@ -12,6 +12,10 @@
<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'">
<a href="JavaScript:void(0);" *ngIf="this.title=='Total Difficulty'" (click)="
ChartFromView('', '', '1 day', true, false); selectedItem = 6
" id="6" #item6 [ngClass]="{ active: selectedItem == item6.id, txt_primay: true }">1 Day</a>
<a href="JavaScript:void(0);" (click)="
ChartFromView('', '', '1 week', true, false); selectedItem = 1
" id="1" #item1 [ngClass]="{ active: selectedItem == item1.id, txt_primay: true }">1 {{'home.WEEK' | translate}}</a>

View File

@ -36,7 +36,11 @@ export class GraphDetailComponent implements OnInit {
private comp: GraphListComponent,
private titleService: Title,
public translate: TransServiceService
) {}
) {
if(this.title=='Total Difficulty'){
this.selectedItem = 6;
}
}
ngOnInit() {
var self = this;
var x = setInterval(function() {
@ -81,7 +85,7 @@ export class GraphDetailComponent implements OnInit {
});
break;
case 'blocks':
this.comp.Difficultyreq().then(res => {
this.comp.blockreq().then(res => {
this.hashdata = this.comp.barGraphData;
this.hashdata.layout.height = 500;
this.title = 'Blocks';
@ -193,7 +197,7 @@ export class GraphDetailComponent implements OnInit {
switch (this.chartType) {
case 'total-difficulty':
this.comp.Difficultyreq(p1, p2, p3, p4, p5).then(res => {
this.comp.Difficultyreq(p1, p2, p3).then(res => {
this.hashdata = this.comp.linearGraphData;
this.hashdata.layout.height = 500;
this.title = 'Total Difficulty';
@ -210,7 +214,7 @@ export class GraphDetailComponent implements OnInit {
});
break;
case 'blocks':
this.comp.Difficultyreq(p1, p2, p3, false, true).then(res => {
this.comp.Difficultyreq(p1, p2, p3).then(res => {
this.hashdata = this.comp.barGraphData;
this.hashdata.layout.height = 500;
this.title = 'Blocks';

View File

@ -25,19 +25,22 @@
</div>
<div class="day_filter">
<a href="JavaScript:void(0);" (click)="
Difficultyreq('', '', '1 week', true, false); selectedItem = 1
Difficultyreq('', '', '1 day'); selectedItem = 6
" id="6" #item6 [ngClass]="{ active: selectedItem == item6.id, txt_primay: true }">1 Day</a>
<a href="JavaScript:void(0);" (click)="
Difficultyreq('', '', '1 week'); selectedItem = 1
" id="1" #item1 [ngClass]="{ active: selectedItem == item1.id, txt_primay: true }">1 {{'home.WEEK' | translate}}</a>
<a href="JavaScript:void(0);" (click)="
Difficultyreq('', '', '15 days', true, false); selectedItem = 2
Difficultyreq('', '', '15 days'); selectedItem = 2
" id="2" #item2 [ngClass]="{ active: selectedItem == item2.id, day15_txt: true }">15 {{'home.DAYS' | translate}}</a>
<a href="JavaScript:void(0);" (click)="
Difficultyreq('', '', '30 days', true, false); selectedItem = 3
Difficultyreq('', '', '30 days'); selectedItem = 3
" id="3" #item3 [ngClass]="{ active: selectedItem == item3.id, day30_txt: true }">30 {{'home.DAYS' | translate}}</a>
<a href="JavaScript:void(0);" (click)="
Difficultyreq('', '', '60 days', true, false); selectedItem = 4
Difficultyreq('', '', '60 days'); selectedItem = 4
" id="4" #item4 [ngClass]="{ active: selectedItem == item4.id, day60_txt: true }">60 {{'home.DAYS' | translate}}</a>
<a href="JavaScript:void(0);" (click)="
Difficultyreq('', '', '3 months', true, false); selectedItem = 5
Difficultyreq('', '', '3 months'); selectedItem = 5
" id="5" #item5 [ngClass]="{ active: selectedItem == item5.id, day3m_txt: true }">3 {{'home.MONTHS' | translate}}</a>
</div>
<div class="explore_all text-right">
@ -108,19 +111,19 @@
</div>
<div class="day_filter">
<a href="JavaScript:void(0);" (click)="
Difficultyreq('', '', '1 week', false, true); selectedItem3 = 1
blockreq('', '', '1 week'); selectedItem3 = 1
" id="1" #item31 [ngClass]="{ active: selectedItem3 == item1.id, txt_primay: true }">1 {{'home.WEEK' | translate}}</a>
<a href="JavaScript:void(0);" (click)="
Difficultyreq('', '', '15 days', false, true); selectedItem3 = 2
blockreq('', '', '15 days'); selectedItem3 = 2
" id="2" #item32 [ngClass]="{ active: selectedItem3 == item2.id, day15_txt: true }">15 {{'home.DAYS' | translate}}</a>
<a href="JavaScript:void(0);" (click)="
Difficultyreq('', '', '30 days', false, true); selectedItem3 = 3
blockreq('', '', '30 days'); selectedItem3 = 3
" id="3" #item33 [ngClass]="{ active: selectedItem3 == item3.id, day30_txt: true }">30 {{'home.DAYS' | translate}}</a>
<a href="JavaScript:void(0);" (click)="
Difficultyreq('', '', '60 days', false, true); selectedItem3 = 4
blockreq('', '', '60 days'); selectedItem3 = 4
" id="4" #item34 [ngClass]="{ active: selectedItem3 == item4.id, day60_txt: true }">60 {{'home.DAYS' | translate}}</a>
<a href="JavaScript:void(0);" (click)="
Difficultyreq('', '', '3 months', false, true); selectedItem3 = 5
blockreq('', '', '3 months'); selectedItem3 = 5
" id="5" #item35 [ngClass]="{ active: selectedItem3 == item5.id, day3m_txt: true }">3 {{'home.MONTHS' | translate}}</a>
</div>
<div class="explore_all text-right">

View File

@ -38,7 +38,7 @@ export class GraphListComponent implements OnInit {
public sg_last: any = '';
public pg_last: any = '';
public selectedItem: Number = 3;
public selectedItem: Number = 6;
public selectedItem3: Number = 3;
public selectedItem2: Number = 3;
public selectedItem4: Number = 3;
@ -70,6 +70,8 @@ export class GraphListComponent implements OnInit {
/* Total Difficulty and blocks chart fetching */
this.Difficultyreq();
this.blockreq();
/* Transcation fee chart fetching */
this.Transcationreq();
@ -374,8 +376,6 @@ export class GraphListComponent implements OnInit {
fromDate = '',
ToDate = '',
interval = '',
fordifficult = true,
forblocks = true,
) {
return new Promise((resolve, reject) => {
let params = new HttpParams();
@ -383,13 +383,12 @@ export class GraphListComponent implements OnInit {
params = params.append('ToDate', ToDate);
params = params.append('Interval', interval);
this.chartService
.apiGetRequest(params, '/blockchain_block/totaldiffnblock')
.apiGetRequest(params, '/blockchain_block/totaldiff')
.subscribe(
res => {
if (res['status'] == 200) {
let DifficultychartDate = res.response.Date;
let BlocksChartDate = res.response.blockDate;
if (fordifficult) {
let DifficultyCuckaroo = res.response.DifficultyCuckaroo;
let DifficultyCuckatoo = res.response.DifficultyCuckatoo;
let DifficultyProgpow = res.response.DifficultyProgpow;
@ -403,12 +402,34 @@ export class GraphListComponent implements OnInit {
DifficultyProgpow,
DifficultyRandomx
);
resolve();
}
if (forblocks) {
},
error => {},
);
});
}
blockreq(
fromDate = '',
ToDate = '',
interval = '',
) {
return new Promise((resolve, reject) => {
let params = new HttpParams();
params = params.append('FromDate', fromDate);
params = params.append('ToDate', ToDate);
params = params.append('Interval', interval);
this.chartService
.apiGetRequest(params, '/blockchain_block/blockcount')
.subscribe(
res => {
if (res['status'] == 200) {
let DifficultychartDate = res.response.Date;
let BlocksChartDate = res.response.blockDate;
let Blockval = res.response.Blocks;
this.brg_last = Blockval[Blockval.length - 1];
this.totalBlocksFunc(BlocksChartDate, Blockval);
}
resolve();
}
},

View File

@ -76,7 +76,7 @@
<!-- title="Cuckaroo : {{ hashvalue.target_difficulty_cuckaroo | number }}, Cuckatoo : {{ hashvalue.target_difficulty_cuckatoo | number }}, Progpow : {{ hashvalue.target_difficulty_progpow | number }}, Randomx : {{ hashvalue.target_difficulty_randomx | number }}" -->
<div class="block_div">
<h6>Difficulty</h6><span
class="blck_value">{{(hashvalue.powalgo == 'Cuckoo') ? (hashvalue.totalcuckoo | number) : (hashvalue.powalgo == 'RandomX') ? (hashvalue.blockchain_block_total_difficulty_randomx | number) : (hashvalue.powalgo == 'ProgPow') ? (hashvalue.blockchain_block_total_difficulty_progpow | number) : 0}}</span>
class="blck_value">{{(hashvalue.powalgo == 'Cuckoo') ? (hashvalue.target_difficulty_cuckatoo | number) : (hashvalue.powalgo == 'RandomX') ? (hashvalue.target_difficulty_randomx | number) : (hashvalue.powalgo == 'ProgPow') ? (hashvalue.target_difficulty_progpow | number) : 0}}</span>
</div>
</div>
<div class="col-6 col-sm-6 col-md-3 tble_col">