Skip to content

Commit

Permalink
Merge pull request #2935 from dusk-network/feature-2934
Browse files Browse the repository at this point in the history
explorer: statistics panel doesn't check to have node data before acc…
  • Loading branch information
ascartabelli authored Nov 14, 2024
2 parents 1158989 + 13c19ed commit b899e78
Show file tree
Hide file tree
Showing 7 changed files with 2,095 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ const marketDataSettleTime = vi.hoisted(() => {
vi.mock("$lib/services", async (importOriginal) => {
/** @type {import("$lib/services")} */
const original = await importOriginal();
const { apiMarketData, apiStats } = await import("$lib/mock-data");
const { apiMarketData, apiStats, nodeLocationsCount } = await import(
"$lib/mock-data"
);
const { current_price: currentPrice, market_cap: marketCap } =
apiMarketData.market_data;

Expand All @@ -26,6 +28,7 @@ vi.mock("$lib/services", async (importOriginal) => {
...original.duskAPI,
getMarketData: () =>
resolveAfter(marketDataSettleTime, { currentPrice, marketCap }),
getNodeLocations: vi.fn().mockResolvedValue(nodeLocationsCount),
getStats: vi.fn().mockResolvedValue(apiStats),
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,9 +332,8 @@ exports[`StatisticsPanel > should render the StatisticsPanel, query for the nece
<div
class="statistics-panel__statistics-item-value"
>
<span>
- - -
</span>
15
</div>
Expand Down Expand Up @@ -366,9 +365,8 @@ exports[`StatisticsPanel > should render the StatisticsPanel, query for the nece
<div
class="statistics-panel__statistics-item-value"
>
<span>
- - -
</span>
North Bergen, US
</div>
Expand Down Expand Up @@ -710,9 +708,8 @@ exports[`StatisticsPanel > should render the StatisticsPanel, query for the nece
<div
class="statistics-panel__statistics-item-value"
>
<span>
- - -
</span>
15
</div>
Expand Down Expand Up @@ -744,9 +741,8 @@ exports[`StatisticsPanel > should render the StatisticsPanel, query for the nece
<div
class="statistics-panel__statistics-item-value"
>
<span>
- - -
</span>
North Bergen, US
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
attributes: null,
canBeStale: false,
compact: true,
data: nodesData ? nodesData[0].count : null,
data: nodesData?.length ? nodesData[0].count : null,
icon: mdiTransitConnectionVariant,
title: "Largest Node Cluster",
},
Expand All @@ -164,7 +164,7 @@
attributes: null,
canBeStale: false,
compact: null,
data: nodesData
data: nodesData?.length
? `${nodesData[0].city}, ${nodesData[0].countryCode}`
: null,
icon: mdiMapMarker,
Expand Down
1 change: 1 addition & 0 deletions explorer/src/lib/mock-data/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ export { default as gqlTransaction } from "./gql-transaction.json";
export { default as gqlTransactionDetails } from "./gql-transaction-details.json";
export { default as gqlTransactions } from "./gql-transactions.json";
export { default as hostProvisioners } from "./host-provisioners.json";
export { default as nodeLocationsCount } from "./node-locations.count.json";
170 changes: 170 additions & 0 deletions explorer/src/lib/mock-data/node-locations.count.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
[
{
"city": "North Bergen",
"country": "United States",
"countryCode": "US",
"lat": 40.793,
"lon": -74.0247,
"count": 15
},
{
"city": "Amsterdam",
"country": "The Netherlands",
"countryCode": "NL",
"lat": 52.352,
"lon": 4.9392,
"count": 15
},
{
"city": "Santa Clara",
"country": "United States",
"countryCode": "US",
"lat": 37.3931,
"lon": -121.962,
"count": 11
},
{
"city": "Frankfurt am Main",
"country": "Germany",
"countryCode": "DE",
"lat": 50.1169,
"lon": 8.6837,
"count": 9
},
{
"city": "Clifton",
"country": "United States",
"countryCode": "US",
"lat": 40.8364,
"lon": -74.1403,
"count": 9
},
{
"city": "Portsmouth",
"country": "United Kingdom",
"countryCode": "GB",
"lat": 50.8544,
"lon": -1.002,
"count": 6
},
{
"city": "Singapore",
"country": "Singapore",
"countryCode": "SG",
"lat": 1.32123,
"lon": 103.695,
"count": 5
},
{
"city": "Nuremberg",
"country": "Germany",
"countryCode": "DE",
"lat": 49.405,
"lon": 11.1617,
"count": 4
},
{
"city": "Helsinki",
"country": "Finland",
"countryCode": "FI",
"lat": 60.1797,
"lon": 24.9344,
"count": 2
},
{
"city": "Alexandria",
"country": "Australia",
"countryCode": "AU",
"lat": -33.9088,
"lon": 151.196,
"count": 1
},
{
"city": "Milan",
"country": "Italy",
"countryCode": "IT",
"lat": 45.4722,
"lon": 9.1922,
"count": 1
},
{
"city": "Sydney",
"country": "Australia",
"countryCode": "AU",
"lat": -33.808,
"lon": 151.1415,
"count": 1
},
{
"city": "Hillsboro",
"country": "United States",
"countryCode": "US",
"lat": 45.5397,
"lon": -122.9638,
"count": 1
},
{
"city": "St Louis",
"country": "United States",
"countryCode": "US",
"lat": 38.6364,
"lon": -90.1985,
"count": 1
},
{
"city": "Slough",
"country": "United Kingdom",
"countryCode": "GB",
"lat": 51.5368,
"lon": -0.6718,
"count": 1
},
{
"city": "Seattle",
"country": "United States",
"countryCode": "US",
"lat": 47.3066,
"lon": -122.2619,
"count": 1
},
{
"city": "Limerick",
"country": "Ireland",
"countryCode": "IE",
"lat": 52.6669,
"lon": -8.6274,
"count": 1
},
{
"city": "Falkenstein",
"country": "Germany",
"countryCode": "DE",
"lat": 50.4777,
"lon": 12.3649,
"count": 1
},
{
"city": "Paris",
"country": "France",
"countryCode": "FR",
"lat": 48.8323,
"lon": 2.4075,
"count": 1
},
{
"city": "Newcastle upon Tyne",
"country": "United Kingdom",
"countryCode": "GB",
"lat": 54.9958,
"lon": -1.6897,
"count": 1
},
{
"city": "Sneek",
"country": "The Netherlands",
"countryCode": "NL",
"lat": 53.0366,
"lon": 5.6858,
"count": 1
}
]
Loading

0 comments on commit b899e78

Please sign in to comment.