Api changes

This commit is contained in:
SuriyaR 2019-07-31 19:43:06 +05:30
parent 89e9190292
commit 57ca6aafe8
6 changed files with 96 additions and 15 deletions

View File

@ -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({

View File

@ -70,7 +70,7 @@
<div class="d-inline-block align-middle ml-2">
<span class="">{{'home.DIFFICULTY' | translate}}</span>
</div>
<h6 class="view_txt">Cuckaroo : {{ hashdata.BlockchainBlockFetchQuery.TotalDifficultyCuckaroo }} | Cuckatoo : {{ hashdata.BlockchainBlockFetchQuery.TotalDifficultyCuckatoo }} <br/> Progpow : {{ hashdata.BlockchainBlockFetchQuery.TotalDifficultyProgpow }} | Randomx : {{ hashdata.BlockchainBlockFetchQuery.TotalDifficultyRandomx }}</h6>
<h6 class="view_txt">{{(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}}</h6>
</div>
<div class="col-sm-6 col-md-4 mt-4 pt-2">
<div class="d-inline-block align-middle">
@ -96,7 +96,7 @@
</div>
<div class="d-inline-block align-middle ml-2">
<span class="">{{'home.ALGORITHM' | translate}}</span>
<h6 class="view_txt">{{ hashdata.BlockchainBlockFetchQuery.PoWAlgorithm }}</h6>
<h6 class="view_txt">{{ hashdata.BlockchainBlockFetchQuery.Proof }}</h6>
</div>
</div>
</div>

View File

@ -261,7 +261,47 @@
</div>
<div [ngClass]="{'col-md-6 col-lg-4 mb-4' : true, 'd-none' : viewchart}">
<div *ngIf="viewchartvar" [ngClass]="{'col-md-6 col-lg-4 mb-4' : true, 'd-none' : viewchart}">
<!-- <div [ngClass]="{'box_shadow' : true, 'invisible h-0' : viewchart}">
<div [ngClass]="{'blocks' : true, 'invisible h-0' : viewchart}">
<h2 class="chart_heading d-inline-block"><a routerLink="/chart/hashrate-growth-chart">HashRate Growth Chart</a></h2>
<span class="txn_count" *ngIf="this.hg_last">{{
this.hg_last | number
}}</span>
<div class="chart_show">
<plotly-plot *ngIf="blockGraphData.data" [data]="blockGraphData.data" [layout]="blockGraphData.layout">
</plotly-plot>
<div *ngIf="!blockGraphData.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)="Transactiondoublelinechartreq('', '', '1 week'); selectedItem9 = 1" id="1" #item1
[ngClass]="{ active: selectedItem9 == item1.id, txt_primay: true }">1 week</a>
<a href="JavaScript:void(0);" (click)="Transactiondoublelinechartreq('', '', '15 days'); selectedItem9 = 2" id="2" #item2
[ngClass]="{ active: selectedItem9 == item2.id, day15_txt: true }">15 days</a>
<a href="JavaScript:void(0);" (click)="Transactiondoublelinechartreq('', '', '30 days'); selectedItem9 = 3" id="3" #item3
[ngClass]="{ active: selectedItem9 == item3.id, day30_txt: true }">30 days</a>
<a href="JavaScript:void(0);" (click)="Transactiondoublelinechartreq('', '', '60 days'); selectedItem9 = 4" id="4" #item4
[ngClass]="{ active: selectedItem9 == item4.id, day60_txt: true }">60 days</a>
<a href="JavaScript:void(0);" (click)="Transactiondoublelinechartreq('', '', '3 months'); selectedItem9 = 5" id="5" #item5
[ngClass]="{ active: selectedItem9 == item5.id, day3m_txt: true }">3 months</a>
</div>
<div class="explore_all text-right">
<a routerLink="/chart/hashrate-growth-chart"><span class="text-uppercase d-block">explore it <i
class="fa fa-long-arrow-right"></i></span></a>
</div>
</div> -->
<div class="box_shadow">
<div class="blocks">
<h2 class="chart_heading d-inline-block">Blocks by Algorithm</h2>
@ -308,7 +348,7 @@
</div>
</div>
</div>
<div [ngClass]="{'col-md-6 col-lg-4 mb-4' : true, 'd-none' : viewchart}">
<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.BLOCK_INTERVAL' | translate}}</h2>
@ -349,7 +389,7 @@
</div>
</div>
</div>
<div [ngClass]="{'col-md-6 col-lg-4 mb-4' : true, 'd-none' : viewchart}">
<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.TRANSACTIONS_VS_DATE' | translate}}</h2>

View File

@ -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,

View File

@ -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';
</div>
<div
*ngIf="viewchartvar"
(click)="viewchartenable()"
routerLink="/all"
class="text-center my-3"
>
<button class="btn btn_primary align-middle">
@ -42,9 +43,15 @@ import { Utils } from 'src/app/shared/utils';
})
export class HomeWorksapceComponent extends Utils
implements OnInit, AfterViewInit {
viewchartvar: boolean = true;
constructor(@Inject(DOCUMENT) public document: Document) {
viewchartvar: boolean;
constructor(@Inject(DOCUMENT) public document: Document,
private router: Router) {
super(document);
if (this.router.url == '/all') {
this.viewchartvar = false;
} else {
this.viewchartvar = true;
}
}
ngOnInit() {}

View File

@ -49,7 +49,8 @@
<div class="block_div"><h6 >Age</h6><span class="blck_value">{{ hashvalue.age }}</span></div>
</div>
<div class="col-6 col-md-3 tble_col">
<div class="block_div"><h6>Difficulty</h6><span class="blck_value" 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 }}">{{ hashvalue.target_difficulty_cuckaroo | number }}, {{ hashvalue.target_difficulty_cuckatoo | number }}, {{ hashvalue.target_difficulty_progpow | number }}, {{ hashvalue.target_difficulty_randomx | number }}</span></div>
<!-- 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.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}}</span></div>
</div>
<div class="col-6 col-sm-6 col-md-3 tble_col">
<div class="block_div"><h6 class="mb-0">Pow Algo</h6><span class="blck_value">{{ hashvalue.powalgo }}</span></div>