Skip to content

Commit

Permalink
upd metroui
Browse files Browse the repository at this point in the history
  • Loading branch information
olton committed Jul 17, 2024
1 parent b943100 commit 004cacc
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 46 deletions.
4 changes: 2 additions & 2 deletions server/API/resolvers/uptime.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {api_registerCache} from "../helpers/cache.js";
import error from "../helpers/error.js";
import api from "../helpers/header.js";
import {INTERVALS} from "../../Modules/consts.js";
import {db_get_address_uptime_position} from "../../Modules/db.js";
import {db_get_account_uptime_position} from "../../Modules/db.js";

const cache = api_registerCache("uptime")

Expand All @@ -13,7 +13,7 @@ export default async (req, res) => {
if (cache.has(publicKey)) {
result = cache.get(publicKey)
} else {
const uptime = await db_get_address_uptime_position(publicKey)
const uptime = await db_get_account_uptime_position(publicKey)
result = {
...uptime,
publicKey,
Expand Down
4 changes: 2 additions & 2 deletions server/Modules/cache.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
db_get_block_stats,
db_get_blocks_stats,
db_get_block_stats_avg,
db_get_blocks_crt,
db_get_blocks_short,
Expand Down Expand Up @@ -43,7 +43,7 @@ export const cache_last_canonical_block = async () => {
}

export const cache_block_stats = async () => {
cache.block_stats = await db_get_block_stats()
cache.block_stats = await db_get_blocks_stats()
}

export const cache_blocks_crt = async () => {
Expand Down
26 changes: 13 additions & 13 deletions server/Modules/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export const db_get_blocks_short = async ({chainStatus = 'canonical', limit = 20
return (await query(sql, [chainStatus, limit, offset])).rows
}

export const db_get_block_stats = async () => {
export const db_get_blocks_stats = async () => {
const sql = `
select * from v_block_stats
`
Expand Down Expand Up @@ -388,7 +388,7 @@ export const db_get_transactions_count_for_account = async ({
return (await query(sql, [Array.isArray(type) ? type : [type], Array.isArray(status) ? status : [status], account])).rows[0].length
}

export const db_get_trans_info = async hash => {
export const db_get_transaction_info = async hash => {
const sql = `
select t.*,
b.height,
Expand Down Expand Up @@ -643,7 +643,7 @@ export const db_get_blocks_count_for_account = async ({
return (await query(sql, [Array.isArray(type) ? type : [type], account])).rows[0].length
}

export const db_get_zkapps = async ({
export const db_get_zkapp = async ({
limit = 50,
offset = 0,
search = null,
Expand Down Expand Up @@ -678,7 +678,7 @@ export const db_get_zkapps = async ({
return result
}

export const db_get_zkapps_count = async ({
export const db_get_zkapp_count = async ({
search = null,
status = [TRANS_STATUS.APPLIED, TRANS_STATUS.FAILED]
}) => {
Expand Down Expand Up @@ -864,7 +864,7 @@ export const db_get_producers_count = async ({search, filter}) => {
return (await query(sql)).rows[0].length
}

export const db_get_block_analytics = async ({distance = 100}) => {
export const db_get_blocks_analytics = async ({distance = 100}) => {
const sql = `
select * from v_block_stats bs
limit $1
Expand All @@ -879,15 +879,15 @@ export const db_get_hard_fork_block = async () => {
return (await query(sql)).rows[0]
}

export const db_get_zkapp_tx_total = async () => {
export const db_get_zkapp_transactions_total = async () => {
const sql = `
select count(*) as count
from v_zkapp_commands_canonical
`
return (await query(sql)).rows[0]["count"]
}

export const db_get_zkapp_tx_count = async (status = 'applied', interval = '30 days') => {
export const db_get_zkapp_transactions_count = async (status = 'applied', interval = '30 days') => {
const _status = status === 'all' ? "1=1" : `zk.status = '${status}'`
const sql = `
select date_trunc('day', to_timestamp(zk.timestamp::bigint / 1000)::timestamp) as day, count(*) as cnt
Expand All @@ -900,7 +900,7 @@ export const db_get_zkapp_tx_count = async (status = 'applied', interval = '30 d
return (await query(sql)).rows
}

export const db_get_zkapp_tx_payments = async (status = 'applied', interval = '30 days') => {
export const db_get_zkapp_transactions_payments = async (status = 'applied', interval = '30 days') => {
const _status = status === 'all' ? "1=1" : `zk.status = '${status}'`
const sql = `
select date_trunc('day', to_timestamp(zk.timestamp::bigint / 1000)::timestamp) as day, sum(fee::bigint) as cnt
Expand Down Expand Up @@ -962,7 +962,7 @@ export const db_get_zkapp_updates_count_by_accounts = async (limit = 100) => {
return (await query(sql)).rows
}

export const db_get_zk_apps_grouped = async (includeNull = false) => {
export const db_get_zkapp_grouped = async (includeNull = false) => {
const filter = includeNull ? "1=1" : "zk.zkapp_uri_id is not null"
const sql = `
select coalesce(nullif(value, ''), 'No Name') as name, count(*)
Expand Down Expand Up @@ -1015,7 +1015,7 @@ export const db_get_account_id = async (pk, create = false) => {
return account_id
}

export const db_get_address_uptime_position = async (publicKey) => {
export const db_get_account_uptime_position = async (publicKey) => {
const id = isNaN(publicKey) ? await db_get_account_id(publicKey) : publicKey
const sql = `
select *
Expand All @@ -1029,7 +1029,7 @@ export const db_get_address_uptime_position = async (publicKey) => {
return result.rows.length ? result.rows[0] : null
}

export const db_get_address_uptime_line = async (publicKey, interval = 'hour', func = 'avg', limit = 48) => {
export const db_get_account_uptime_line = async (publicKey, interval = 'hour', func = 'avg', limit = 48) => {
const id = isNaN(publicKey) ? await db_get_account_id(publicKey) : publicKey
const sql = `
select
Expand Down Expand Up @@ -1254,7 +1254,7 @@ export const db_get_user_tx_per_epoch = async (limit = 100) => {
return (await query(sql, [limit])).rows
}

export const db_get_zkapps_tx_per_epoch = async (limit = 100) => {
export const db_get_zkapp_transactions_per_epoch = async (limit = 100) => {
const sql = `
select calc_epoch_since_genesis(b.global_slot_since_genesis::integer) as epoch,
count(*) as tx_zkapps_count
Expand Down Expand Up @@ -1284,7 +1284,7 @@ export const db_get_snarky_per_epoch = async (limit = 100) => {
return (await query(sql, [limit])).rows
}

export const db_get_tx_status_per_epoch = async (limit = 100) => {
export const db_get_transactions_status_per_epoch = async (limit = 100) => {
const sql = `
with
failed_transactions as
Expand Down
46 changes: 23 additions & 23 deletions server/Modules/websocket.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import WebSocket, {WebSocketServer} from "ws";
import WebSocket from "ws";
import {
db_get_account_balance_history,
db_get_account_delegators,
Expand All @@ -11,7 +11,7 @@ import {
db_get_account_transactions_history,
db_get_accounts,
db_get_accounts_count,
db_get_block_analytics,
db_get_blocks_analytics,
db_get_block_info,
db_get_block_internal_commands,
db_get_block_trans,
Expand All @@ -32,25 +32,25 @@ import {
db_get_price_minutes,
db_get_producers,
db_get_producers_count, db_get_snarky_per_epoch,
db_get_trans_info,
db_get_transaction_info,
db_get_transactions,
db_get_transactions_count,
db_get_transactions_count_for_account,
db_get_transactions_for_account,
db_get_tx_status_per_epoch,
db_get_transactions_status_per_epoch,
db_get_user_tx_per_epoch,
db_get_zk_apps_grouped,
db_get_zkapp_grouped,
db_get_zkapp_account_updates,
db_get_zkapp_account_updates_interval,
db_get_zkapp_account_updates_total,
db_get_zkapp_apps_count,
db_get_zkapp_tx_count,
db_get_zkapp_tx_payments,
db_get_zkapp_tx_total,
db_get_zkapp_transactions_count,
db_get_zkapp_transactions_payments,
db_get_zkapp_transactions_total,
db_get_zkapp_updates_count_by_accounts,
db_get_zkapps,
db_get_zkapps_count,
db_get_zkapps_tx_per_epoch,
db_get_zkapp,
db_get_zkapp_count,
db_get_zkapp_transactions_per_epoch,
db_save_ip
} from "./db.js";
import {ql_get_account_info, ql_get_pool, ql_get_snark_jobs} from "./graphql.js";
Expand Down Expand Up @@ -183,7 +183,7 @@ export const websocket = () => {
break
}
case "trans_info": {
response(ws, channel, await db_get_trans_info(data.hash))
response(ws, channel, await db_get_transaction_info(data.hash))
break
}
case "accounts": {
Expand Down Expand Up @@ -248,8 +248,8 @@ export const websocket = () => {
break
}
case "zkapps": {
const rows = await db_get_zkapps({...data})
const length = await db_get_zkapps_count({...data})
const rows = await db_get_zkapp({...data})
const length = await db_get_zkapp_count({...data})
response(ws, channel, {rows, length})
break
}
Expand Down Expand Up @@ -279,20 +279,20 @@ export const websocket = () => {
break
}
case "block_analytics" : {
const rows = await db_get_block_analytics({...data})
const rows = await db_get_blocks_analytics({...data})
response(ws, channel, {rows})
break
}
case "zkapp-transactions": {
const total = await db_get_zkapp_tx_total()
const applied = await db_get_zkapp_tx_count('applied', data.interval)
const failed = await db_get_zkapp_tx_count('failed', data.interval)
const total = await db_get_zkapp_transactions_total()
const applied = await db_get_zkapp_transactions_count('applied', data.interval)
const failed = await db_get_zkapp_transactions_count('failed', data.interval)
response(ws, channel, {applied, failed, total})
break
}
case "zkapp-payments": {
const applied = await db_get_zkapp_tx_payments('applied', data.interval)
const failed = await db_get_zkapp_tx_payments('failed', data.interval)
const applied = await db_get_zkapp_transactions_payments('applied', data.interval)
const failed = await db_get_zkapp_transactions_payments('failed', data.interval)
response(ws, channel, {applied, failed})
break
}
Expand All @@ -308,7 +308,7 @@ export const websocket = () => {
}
case "zkapp-apps": {
const app_count = await db_get_zkapp_apps_count()
const app_grouped = await db_get_zk_apps_grouped()
const app_grouped = await db_get_zkapp_grouped()
response(ws, channel, {app_count, app_grouped})
break
}
Expand Down Expand Up @@ -352,11 +352,11 @@ export const websocket = () => {
break
}
case "user-tx-status-per-epoch": {
response(ws, channel, await db_get_tx_status_per_epoch())
response(ws, channel, await db_get_transactions_status_per_epoch())
break
}
case "zkapps-tx-per-epoch": {
response(ws, channel, await db_get_zkapps_tx_per_epoch())
response(ws, channel, await db_get_zkapp_transactions_per_epoch())
break
}
case "snarky-per-epoch": {
Expand Down
Loading

0 comments on commit 004cacc

Please sign in to comment.