Skip to content

Commit

Permalink
Fix database size metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
muXxer committed Apr 22, 2024
1 parent c02facf commit 45fa934
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/app/components/layout/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,22 +137,25 @@ class Header extends AsyncComponent<RouteComponentProps & HeaderProps, HeaderSta
WebSocketTopic.DatabaseSizeMetric,
data => {
if (data) {
const nonNull = data.databaseSizes.filter(d => d !== undefined && d !== null);

const dbSizeTotalValues = nonNull
.map(d => d.total);

this.setState({ dbSizeTotal: dbSizeTotalValues });

let dbSizeTotalFormatted = "-";
if (dbSizeTotalValues.length > 0) {
dbSizeTotalFormatted = FormatHelper.size(dbSizeTotalValues[0]);
if (data.databaseSizes.length > 0) {
dbSizeTotalFormatted = FormatHelper.size(data.databaseSizes[0].total);
}

if (dbSizeTotalFormatted !== this.state.dbSizeTotalFormatted) {
this.setState({ dbSizeTotalFormatted });
}
}
},
allData => {
const nonNull = allData.filter(d => d?.databaseSizes !== undefined && d?.databaseSizes !== null);

const dbSizeTotalValues = nonNull
.map(d => d.databaseSizes.map(s => s.total));

const dbSizeTotalFlattened = dbSizeTotalValues.flat();

this.setState({ dbSizeTotal: dbSizeTotalFlattened });
});

this._gossipMetricsSubscription = this._metricsService.subscribe<IGossipMetrics>(
Expand Down

0 comments on commit 45fa934

Please sign in to comment.