diff --git a/server/controllers/BlockchainBlock.ts b/server/controllers/BlockchainBlock.ts index 91d1842..c0f88cc 100644 --- a/server/controllers/BlockchainBlock.ts +++ b/server/controllers/BlockchainBlock.ts @@ -219,6 +219,10 @@ export class BlockchainBlockController { * description: Enter the Algorithm Type * in: query * type: string + * - name: Difftype + * description: Enter the Difficulty Type + * in: query + * type: string * responses: * 200: * description: Total Difficulty fetched successfully @@ -1133,8 +1137,14 @@ export class BlockchainBlockController { } var alog_type = TotalDifficultyNBlockRequestData.Type; - - const TotalDifficultyNBlockQuery = await getConnection() + var Difftype = TotalDifficultyNBlockRequestData.Difftype; + if (TotalDifficultyNBlockRequestData.Interval && TotalDifficultyNBlockRequestData.Interval != '1 day') { + var dateFormat = 'YYYY-MM-DD'; + }else{ + var dateFormat = 'HH:mm'; + } + if(Difftype == "target"){ + var TotalDifficultyNBlockQuery = await getConnection() .query( "SELECT a.hash, a.tarket_difficulty, a.date FROM(select 1 as hash, (total_difficulty_"+alog_type+" - LAG(total_difficulty_"+alog_type+") OVER (ORDER BY total_difficulty_"+alog_type+")) AS tarket_difficulty, \ DATE_TRUNC('minute', timestamp at time zone '" + @@ -1147,6 +1157,49 @@ export class BlockchainBlockController { .catch(err_msg => { next(err_msg); }); + }else if(Difftype == "solution"){ + var TotalDifficultyNBlockQuery = await getConnection() + .query( + "SELECT a.hash, a.tarket_difficulty, a.date FROM(select 1 as hash, (total_difficulty_"+alog_type+" - LAG(total_difficulty_"+alog_type+") OVER (ORDER BY total_difficulty_"+alog_type+")) AS tarket_difficulty, \ + DATE_TRUNC('minute', timestamp at time zone '" + + process.env.TIME_ZONE + + "') as date \ + from blockchain_block where " + + timeIntervalQry + + " order by height) as a WHERE a.tarket_difficulty IS NOT NULL", + ) + .catch(err_msg => { + next(err_msg); + }); + }else if(Difftype == "total"){ + var TotalDifficultyNBlockQuery = await getConnection() + .query( + "select 1 as hash, total_difficulty_"+alog_type+" as tarket_difficulty, \ + DATE_TRUNC('minute', timestamp at time zone '" + + process.env.TIME_ZONE + + "') as date \ + from blockchain_block where " + + timeIntervalQry + + " order by height", + ) + .catch(err_msg => { + next(err_msg); + }); + }else{ + var TotalDifficultyNBlockQuery = await getConnection() + .query( + "SELECT a.hash, a.tarket_difficulty, a.date FROM(select 1 as hash, (total_difficulty_"+alog_type+" - LAG(total_difficulty_"+alog_type+") OVER (ORDER BY total_difficulty_"+alog_type+")) AS tarket_difficulty, \ + DATE_TRUNC('minute', timestamp at time zone '" + + process.env.TIME_ZONE + + "') as date \ + from blockchain_block where " + + timeIntervalQry + + " order by height) as a WHERE a.tarket_difficulty IS NOT NULL", + ) + .catch(err_msg => { + next(err_msg); + }); + } let date = [], //DifficultyCuckaroo = [], //DifficultyCuckatoo = [], @@ -1157,7 +1210,7 @@ export class BlockchainBlockController { TotalDifficultyNBlockQuery.forEach(e => { //date.indexOf(moment(e.date).format('YYYY-MM-DD')) < 0 ? - date.push(moment(e.date).format('YYYY-MM-DD')); + date.push(moment(e.date).format(dateFormat)); // DifficultyCuckaroo.push(parseInt(e.total_difficulty_cuckaroo)); // DifficultyCuckatoo.push(parseInt(e.total_difficulty_cuckatoo)); // DifficultyProgpow.push(parseInt(e.total_difficulty_progpow)); @@ -1168,7 +1221,7 @@ export class BlockchainBlockController { response.status(200).json({ status: 200, timestamp: Date.now(), - message: 'Total Difficulty and Blocks Data fetched Successfully', + message: 'Difficulty and Blocks Data fetched Successfully', response: { Date: date, // DifficultyCuckaroo: DifficultyCuckaroo, diff --git a/server/dtos/BlockchainBlock.ts b/server/dtos/BlockchainBlock.ts index c17ee97..b7a83b5 100644 --- a/server/dtos/BlockchainBlock.ts +++ b/server/dtos/BlockchainBlock.ts @@ -139,4 +139,7 @@ export class TotalDifficultyNBlockDto { @IsString() public Type: string; + @IsString() + public Difftype: string; + } diff --git a/server/i18n/de.json b/server/i18n/de.json index d98ee2e..e062121 100644 --- a/server/i18n/de.json +++ b/server/i18n/de.json @@ -1,5 +1,5 @@ { - "total-difficulty" : "Gesamtschwierigkeit", + "difficulty" : "Schwierigkeit", "transactions-by-time" : "Transaktionen im Zeitverlauf", "blocks" : "Blöcke", "transaction-fees" : "Transkationsgebühren", diff --git a/server/i18n/en.json b/server/i18n/en.json index fe05d36..73ad174 100644 --- a/server/i18n/en.json +++ b/server/i18n/en.json @@ -1,5 +1,5 @@ { - "total-difficulty" : "Total Difficulty", + "difficulty" : "Difficulty", "transactions-by-time" : "Transactions over time", "blocks" : "Blocks", "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 43feb74..92821bd 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 @@ -8,7 +8,7 @@