Skip to content

Commit

Permalink
Feat/mfx power conversion (#327)
Browse files Browse the repository at this point in the history
  • Loading branch information
jgryffindor authored Nov 21, 2024
1 parent 0651a5d commit c16028c
Show file tree
Hide file tree
Showing 12 changed files with 2,265 additions and 2,342 deletions.
19 changes: 3 additions & 16 deletions client/src/api/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,10 @@ export function getMetricCurrent(

export function getMetricSeries(
stat?: string,
{from = FROM, to = TO } = {}
smoothed?: boolean,
{from = FROM, to = TO } = {},
) {
return get(`metrics/${stat}/series`, { from, to });
return get(`metrics/${stat}/series`, { from, to, smoothed });
}

export function getMetricTransformCurrent(
Expand All @@ -105,20 +106,6 @@ export function getMetricTransformSeries(
return get(`metrics/transforms/${stat}/${transform}/series`, { from, to });
}

export function getMetricSystemWideCurrent(
metric?: string,
) {
return get(`metrics/systemwide/${metric}/current`);
}

export function getMetricSystemWideSeries(
metric?: string,
{from = FROM, to = TO } = {}
) {
return get(`metrics/systemwide/${metric}/series`, { from, to });
}

export function getLocations() {
return get("location");
}

20 changes: 15 additions & 5 deletions client/src/pages/metrics/networkMetrics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,28 @@ export function NetworkMetrics() {
return (
<>
<Heading as='h4' size='md' py="5" pl="5" >Blockchain Network Totals</Heading>
<SimpleGrid id="blockchain" columns={{ base: 1, sm: 1, md: 2, lg: 4 }} gap="6" mt={2}>
<SimpleGrid id="blockchain" columns={{ base: 1, sm: 1, md: 2, lg: 3 }} gap="6" mt={2}>
<Box backgroundColor="transparent">
<MetricStat label="Total Blocks Produced" metric="totalblocks" systemwide />
<MetricStat label="POWER : MFX Conversion Rate" metric="mfxpowerconversion" unit=": 1" fixedDecimals={2} />
<MetricChart label="POWER:MFX" type="area" metric="mfxpowerconversion" from={"now-180d"} to={"now"} fixedDecimals={2} smoothed={false} />
</Box>
<Box backgroundColor="transparent">
<MetricStat label="Total Transactions" metric="totaltransactions" systemwide />
<MetricStat label="Total Addresses" metric="totaladdresses" />
<MetricChart label="Total Addresses" type="area" metric="totaladdresses" from={"now-60d"} to={"now"} fixedDecimals={0} ytitle="Addresses" smoothed={false} />
</Box>
<Box backgroundColor="transparent">
<MetricStat label="Total Addresses" metric="totaladdresses" systemwide />
<MetricStat label="Total Tokens" metric="totaltokens" />
<MetricChart label="Total Tokens" type="area" metric="totaltokens" from={"now-60d"} to={"now"} fixedDecimals={0} ytitle="Tokens" smoothed={false} />
</Box>
</SimpleGrid>
<SimpleGrid id="blockchain" columns={{ base: 1, sm: 1, md: 2, lg: 2 }} gap="6" mt={2}>
<Box backgroundColor="transparent">
<MetricStat label="Total Blocks Produced" metric="totalnetworkblocks" />
<MetricChart label="Total Blocks Produced" type="area" metric="totalnetworkblocks" from={"now-60d"} to={"now"} fixedDecimals={0} ytitle="Blocks" smoothed={false} />
</Box>
<Box backgroundColor="transparent">
<MetricStat label="Total Tokens" metric="totaltokens" from={"now-1d"} to={"now"} />
<MetricStat label="Total Transactions" metric="totaltransactions" />
<MetricChart label="Total Transactions" type="area" metric="totaltransactions" from={"now-60d"} to={"now"} fixedDecimals={0} ytitle="Transactions" smoothed={false} />
</Box>
</SimpleGrid>
<Heading as='h4' size='md' py="5" pl="5" >Nodes</Heading>
Expand Down
4 changes: 3 additions & 1 deletion client/src/ui/metric-chart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ interface StatProps {
conversion?: Function;
from?: string;
to?: string;
smoothed?: boolean;
fixedDecimals?: number;
transform?: string;
}
Expand All @@ -40,6 +41,7 @@ export function MetricChart({
conversion,
from,
to,
smoothed = true,
xtitle,
ytitle,
fixedDecimals,
Expand All @@ -54,7 +56,7 @@ export function MetricChart({
metricQuery = getMetricTransformSeries(metric, transform, {from: from, to: to })
}
else {
metricQuery = getMetricSeries(metric,{from: from, to: to })
metricQuery = getMetricSeries(metric, smoothed, {from: from, to: to })
}

const { data: queryData, isError, isLoading } = useQuery([metric + "series"], metricQuery, {
Expand Down
7 changes: 1 addition & 6 deletions client/src/ui/metric-stat.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useEffect } from "react"
import { Stat as BaseStat, StatLabel, StatNumber } from "@liftedinit/ui";
import { useQuery } from "@tanstack/react-query";
import { getMetricCurrent, getMetricTransformCurrent, getMetricSystemWideCurrent } from "api";
import { getMetricCurrent, getMetricTransformCurrent } from "api";
import { Box, Center, Spinner } from "@liftedinit/ui";
import { useBgColor, LONG_STALE_INTERVAL, LONG_REFRESH_INTERVAL } from "utils";

Expand All @@ -14,7 +14,6 @@ interface StatProps {
unit?: string;
fixedDecimals?: number;
transform?: string;
systemwide?: boolean;
}

interface QueryData {
Expand All @@ -38,7 +37,6 @@ export function MetricStat({
fixedDecimals,
unit,
transform,
systemwide,
}: StatProps) {

const bg = useBgColor();
Expand All @@ -50,9 +48,6 @@ export function MetricStat({
if (transform) {
metricQuery = getMetricTransformCurrent(metric, transform, {from: from, to: to })
}
else if (systemwide) {
metricQuery = getMetricSystemWideCurrent(metric)
}
else {
metricQuery = getMetricCurrent(metric, {from: from, to: to })
}
Expand Down
Loading

0 comments on commit c16028c

Please sign in to comment.