mirror of
https://github.com/mempool/mempool.git
synced 2025-02-23 06:35:15 +01:00
Merge branch 'master' into nymkappa/feature/block-fee-usd-chart
This commit is contained in:
commit
ee058deb74
2 changed files with 41 additions and 2 deletions
|
@ -4,9 +4,34 @@ import DB from '../../database';
|
||||||
class NodesApi {
|
class NodesApi {
|
||||||
public async $getNode(public_key: string): Promise<any> {
|
public async $getNode(public_key: string): Promise<any> {
|
||||||
try {
|
try {
|
||||||
const query = `SELECT nodes.*, (SELECT COUNT(*) FROM channels WHERE channels.status < 2 AND (channels.node1_public_key = ? OR channels.node2_public_key = ?)) AS channel_count, (SELECT SUM(capacity) FROM channels WHERE channels.status < 2 AND (channels.node1_public_key = ? OR channels.node2_public_key = ?)) AS capacity, (SELECT AVG(capacity) FROM channels WHERE status < 2 AND (node1_public_key = ? OR node2_public_key = ?)) AS channels_capacity_avg FROM nodes WHERE public_key = ?`;
|
const query = `
|
||||||
|
SELECT nodes.*, geo_names_as.names as as_organization, geo_names_city.names as city,
|
||||||
|
geo_names_country.names as country, geo_names_subdivision.names as subdivision,
|
||||||
|
(SELECT Count(*)
|
||||||
|
FROM channels
|
||||||
|
WHERE channels.status < 2 AND ( channels.node1_public_key = ? OR channels.node2_public_key = ? )) AS channel_count,
|
||||||
|
(SELECT Sum(capacity)
|
||||||
|
FROM channels
|
||||||
|
WHERE channels.status < 2 AND ( channels.node1_public_key = ? OR channels.node2_public_key = ? )) AS capacity,
|
||||||
|
(SELECT Avg(capacity)
|
||||||
|
FROM channels
|
||||||
|
WHERE status < 2 AND ( node1_public_key = ? OR node2_public_key = ? )) AS channels_capacity_avg
|
||||||
|
FROM nodes
|
||||||
|
LEFT JOIN geo_names geo_names_as on geo_names_as.id = as_number
|
||||||
|
LEFT JOIN geo_names geo_names_city on geo_names_city.id = city_id
|
||||||
|
LEFT JOIN geo_names geo_names_subdivision on geo_names_subdivision.id = subdivision_id
|
||||||
|
LEFT JOIN geo_names geo_names_country on geo_names_country.id = country_id
|
||||||
|
WHERE public_key = ?
|
||||||
|
`;
|
||||||
const [rows]: any = await DB.query(query, [public_key, public_key, public_key, public_key, public_key, public_key, public_key]);
|
const [rows]: any = await DB.query(query, [public_key, public_key, public_key, public_key, public_key, public_key, public_key]);
|
||||||
|
if (rows.length > 0) {
|
||||||
|
rows[0].as_organization = JSON.parse(rows[0].as_organization);
|
||||||
|
rows[0].subdivision = JSON.parse(rows[0].subdivision);
|
||||||
|
rows[0].city = JSON.parse(rows[0].city);
|
||||||
|
rows[0].country = JSON.parse(rows[0].country);
|
||||||
return rows[0];
|
return rows[0];
|
||||||
|
}
|
||||||
|
return null;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.err('$getNode error: ' + (e instanceof Error ? e.message : e));
|
logger.err('$getNode error: ' + (e instanceof Error ? e.message : e));
|
||||||
throw e;
|
throw e;
|
||||||
|
|
|
@ -33,6 +33,14 @@
|
||||||
<app-sats [satoshis]="node.channels_capacity_avg"></app-sats><app-fiat [value]="node.channels_capacity_avg" digitsInfo="1.0-0"></app-fiat>
|
<app-sats [satoshis]="node.channels_capacity_avg"></app-sats><app-fiat [value]="node.channels_capacity_avg" digitsInfo="1.0-0"></app-fiat>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr *ngIf="node.country && node.city && node.subdivision">
|
||||||
|
<td i18n="location">Location</td>
|
||||||
|
<td>{{ node.city.en }}, {{ node.subdivision.en }}<br>{{ node.country.en }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr *ngIf="node.country && !node.city">
|
||||||
|
<td i18n="location">Location</td>
|
||||||
|
<td>{{ node.country.en }}</td>
|
||||||
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
@ -56,6 +64,12 @@
|
||||||
<td i18n="address.balance">Color</td>
|
<td i18n="address.balance">Color</td>
|
||||||
<td><div [ngStyle]="{'color': node.color}">{{ node.color }}</div></td>
|
<td><div [ngStyle]="{'color': node.color}">{{ node.color }}</div></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr *ngIf="node.country">
|
||||||
|
<td i18n="isp">ISP</td>
|
||||||
|
<td>
|
||||||
|
{{ node.as_organization }} [ASN {{node.as_number}}]
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Reference in a new issue