Skip to content

Commit

Permalink
[CodeFactor] Apply fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
code-factor committed Jul 11, 2023
1 parent c7d6721 commit d56f080
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions hapi/src/services/stats.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const getNodesSummary = async () => {
type
`)

rows.forEach(row => {
rows.forEach((row) => {
payload[row.node_type || 'unknown'] = row.nodes_count
total += row.nodes_count
})
Expand Down Expand Up @@ -121,12 +121,12 @@ const getBlockDistribution = async (range = '1 day') => {
`
const data = await hasuraUtil.request(query, { startTime })

data.items.forEach(item => {
data.items.forEach((item) => {
totalBloks += item.blocks
})

return data.items
.map(item => ({
.map((item) => ({
account: item.producer || 'N/A',
blocks: item.blocks,
percent: item.blocks === 0 ? 0 : item.blocks / totalBloks
Expand Down Expand Up @@ -227,7 +227,7 @@ const getCurrentMissedBlock = async () => {

let newData = data

rows.forEach(element => {
rows.forEach((element) => {
if (newData[element.account]) {
newData = {
...newData,
Expand All @@ -250,7 +250,7 @@ const getCurrentMissedBlock = async () => {
getCurrentMissedBlock()
}

const udpateStats = async payload => {
const udpateStats = async (payload) => {
const mutation = `
mutation ($id: uuid!, $payload: stat_set_input!) {
update_stat_by_pk(pk_columns: {id: $id}, _set: $payload) {
Expand All @@ -261,7 +261,7 @@ const udpateStats = async payload => {
await hasuraUtil.request(mutation, { id: STAT_ID, payload })
}

const insertStats = async payload => {
const insertStats = async (payload) => {
const mutation = `
mutation ($payload: stat_insert_input!) {
insert_stat_one(object: $payload) {
Expand All @@ -280,7 +280,7 @@ const getLastTPSAllTimeHigh = async () => {
return stats.tps_all_time_high
}

const getTimestampBlock = async position => {
const getTimestampBlock = async (position) => {
const query = `
query {
blocks: block_history(limit: 1, order_by: {block_num: ${
Expand Down Expand Up @@ -378,8 +378,6 @@ const syncTPSAllTimeHigh = async () => {
}
})
syncTPSAllTimeHigh()

return
}

const sync = async () => {
Expand All @@ -396,14 +394,15 @@ const sync = async () => {
await insertStats(payload)
}

const getTransactionsStats = async range => {
const getTransactionsStats = async (range) => {
const transactionsStats = await getTransactionsInTimeRage(
moment().subtract(1, range),
moment()
)

return {
[`transactions_in_last_${range}`]: transactionsStats?.transactions_count || 0,
[`transactions_in_last_${range}`]:
transactionsStats?.transactions_count || 0,
[`average_cpu_usage_in_last_${range}`]: transactionsStats?.cpu_usage || 0,
[`average_net_usage_in_last_${range}`]: transactionsStats?.net_usage || 0
}
Expand Down

0 comments on commit d56f080

Please sign in to comment.