clone:legacy
This commit is contained in:
91
prisma/views/DKON/NodeDashboard.sql
Normal file
91
prisma/views/DKON/NodeDashboard.sql
Normal file
@@ -0,0 +1,91 @@
|
||||
WITH `ranking_list` AS (
|
||||
SELECT
|
||||
`n`.`id` AS `id`,
|
||||
`n`.`nickname` AS `nickname`,
|
||||
`n`.`address` AS `address`,
|
||||
`n`.`stakedBalance` AS `stakedBalance`,
|
||||
`n`.`computingPower` AS `computingPower`,
|
||||
`n`.`childrenAccumulatedBalance` AS `childrenAccumulatedBalance`,
|
||||
rank() OVER (
|
||||
ORDER BY
|
||||
`n`.`stakedBalance`
|
||||
) AS `ranking`
|
||||
FROM
|
||||
`DKON`.`Node` `n`
|
||||
WHERE
|
||||
(`n`.`stakedBalance` >= 200000000000000000000)
|
||||
ORDER BY
|
||||
`n`.`stakedBalance` DESC
|
||||
)
|
||||
SELECT
|
||||
`ranking_list`.`id` AS `id`,
|
||||
`ranking_list`.`nickname` AS `nickname`,
|
||||
`ranking_list`.`address` AS `address`,
|
||||
`ranking_list`.`ranking` AS `ranking`,
|
||||
round((`ranking_list`.`stakedBalance` / pow(10, 18)), 4) AS `stakedBalance`,
|
||||
round((`ranking_list`.`computingPower` / pow(10, 18)), 4) AS `computingPower`,
|
||||
round(
|
||||
(
|
||||
`ranking_list`.`childrenAccumulatedBalance` / pow(10, 18)
|
||||
),
|
||||
4
|
||||
) AS `childrenAccumulatedBalance`,
|
||||
`ranking_list`.`stakedBalance` AS `stakedBalanceOrig`,
|
||||
`ranking_list`.`computingPower` AS `computingPowerOrig`,
|
||||
`ranking_list`.`childrenAccumulatedBalance` AS `childrenAccumulatedBalanceOrig`,
|
||||
(
|
||||
`ranking_list`.`ranking` / (
|
||||
SELECT
|
||||
sum(`ranking_list`.`ranking`)
|
||||
FROM
|
||||
`ranking_list`
|
||||
)
|
||||
) AS `ranking_portion`,
|
||||
(
|
||||
`ranking_list`.`stakedBalance` / (
|
||||
SELECT
|
||||
sum(`ranking_list`.`stakedBalance`)
|
||||
FROM
|
||||
`ranking_list`
|
||||
)
|
||||
) AS `staked_portion`,
|
||||
(
|
||||
`ranking_list`.`computingPower` / (
|
||||
SELECT
|
||||
sum(`ranking_list`.`computingPower`)
|
||||
FROM
|
||||
`ranking_list`
|
||||
)
|
||||
) AS `computingPower_portion`,
|
||||
(
|
||||
`ranking_list`.`childrenAccumulatedBalance` / (
|
||||
SELECT
|
||||
sum(`ranking_list`.`childrenAccumulatedBalance`)
|
||||
FROM
|
||||
`ranking_list`
|
||||
)
|
||||
) AS `childrenAccumulatedBalance_portion`,
|
||||
(
|
||||
(
|
||||
`ranking_list`.`ranking` / (
|
||||
SELECT
|
||||
sum(`ranking_list`.`ranking`)
|
||||
FROM
|
||||
`ranking_list`
|
||||
)
|
||||
) * 66666.666666666666
|
||||
) AS `ranking_estimated_dist`,
|
||||
(
|
||||
(
|
||||
`ranking_list`.`computingPower` / (
|
||||
SELECT
|
||||
sum(`ranking_list`.`computingPower`)
|
||||
FROM
|
||||
`ranking_list`
|
||||
)
|
||||
) * 66666.666666666666
|
||||
) AS `computingPower_estimated_dist`
|
||||
FROM
|
||||
`ranking_list`
|
||||
GROUP BY
|
||||
`ranking_list`.`address`
|
||||
Reference in New Issue
Block a user