Add capacity per AS

This commit is contained in:
nymkappa
2022-07-16 11:32:48 +02:00
parent 28cf0f71eb
commit 3edd6f23a5
3 changed files with 19 additions and 10 deletions

View File

@@ -96,10 +96,12 @@ class NodesApi {
public async $getNodesAsShare() {
try {
let query = `SELECT names, COUNT(*) as nodesCount from nodes
let query = `SELECT names, COUNT(DISTINCT nodes.public_key) as nodesCount, SUM(capacity) as capacity
FROM nodes
JOIN geo_names ON geo_names.id = nodes.as_number
JOIN channels ON channels.node1_public_key = nodes.public_key OR channels.node2_public_key = nodes.public_key
GROUP BY as_number
ORDER BY COUNT(*) DESC
ORDER BY COUNT(DISTINCT nodes.public_key) DESC
`;
const [nodesCountPerAS]: any = await DB.query(query);
@@ -112,6 +114,7 @@ class NodesApi {
name: JSON.parse(as.names),
count: as.nodesCount,
share: Math.floor(as.nodesCount / nodesWithAS[0].total * 10000) / 100,
capacity: as.capacity,
})
}