Show division and ASN number

This commit is contained in:
nymkappa 2022-07-12 21:28:02 +02:00
parent f2983e28a3
commit 6e09a1c96b
No known key found for this signature in database
GPG Key ID: E155910B16E8BD04
2 changed files with 11 additions and 7 deletions

View File

@ -5,7 +5,8 @@ class NodesApi {
public async $getNode(public_key: string): Promise<any> { public async $getNode(public_key: string): Promise<any> {
try { try {
const query = ` const query = `
SELECT nodes.*, geo_names_as.names as as_organization, geo_names_city.names as city, geo_names_country.names as country, 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(*) (SELECT Count(*)
FROM channels FROM channels
WHERE channels.status < 2 AND ( channels.node1_public_key = ? OR channels.node2_public_key = ? )) AS channel_count, WHERE channels.status < 2 AND ( channels.node1_public_key = ? OR channels.node2_public_key = ? )) AS channel_count,
@ -18,12 +19,14 @@ class NodesApi {
FROM nodes FROM nodes
LEFT JOIN geo_names geo_names_as on geo_names_as.id = as_number 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_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 LEFT JOIN geo_names geo_names_country on geo_names_country.id = country_id
WHERE public_key = ? 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) { if (rows.length > 0) {
rows[0].as_organization = JSON.parse(rows[0].as_organization); 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].city = JSON.parse(rows[0].city);
rows[0].country = JSON.parse(rows[0].country); rows[0].country = JSON.parse(rows[0].country);
return rows[0]; return rows[0];

View File

@ -33,12 +33,13 @@
<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"> <tr *ngIf="node.country && node.city && node.subdivision">
<td i18n="location">Location</td> <td i18n="location">Location</td>
<td> <td>{{ node.city.en }}, {{ node.subdivision.en }}<br>{{ node.country.en }}</td>
<span *ngIf="node.country">{{ node.country.en }}</span> </tr>
<span *ngIf="node.city"> ({{ node.city.en }})</span> <tr *ngIf="node.country && !node.city">
</td> <td i18n="location">Location</td>
<td>{{ node.country.en }}</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
@ -66,7 +67,7 @@
<tr *ngIf="node.country"> <tr *ngIf="node.country">
<td i18n="isp">ISP</td> <td i18n="isp">ISP</td>
<td> <td>
{{ node.as_organization }} {{ node.as_organization }} [ASN {{node.as_number}}]
</td> </td>
</tr> </tr>
</tbody> </tbody>