fix stats in API

This commit is contained in:
Tao Bojlen 2018-09-01 19:34:00 +02:00
parent ef18276c21
commit 478a3b91f7
4 changed files with 13 additions and 2 deletions

View File

@ -8,6 +8,7 @@
"@blueprintjs/select": "^3.1.0",
"classnames": "^2.2.6",
"cross-fetch": "^2.2.2",
"moment": "^2.22.2",
"normalize.css": "^8.0.0",
"react": "^16.4.2",
"react-dom": "^16.4.2",

View File

@ -1,3 +1,4 @@
import * as moment from 'moment';
import * as React from 'react';
import { connect } from 'react-redux';
import { Dispatch } from 'redux';
@ -74,6 +75,7 @@ class SidebarImpl extends React.Component<ISidebarProps> {
const userCount = this.props.instanceDetails!.userCount;
const statusCount = this.props.instanceDetails!.statusCount;
const domainCount = this.props.instanceDetails!.domainCount;
const lastUpdated = this.props.instanceDetails!.lastUpdated;
if (!userCount && !statusCount && !domainCount) {
return;
}
@ -94,6 +96,10 @@ class SidebarImpl extends React.Component<ISidebarProps> {
<td>Known peers</td>
<td>{domainCount || "Unknown"}</td>
</tr>
<tr>
<td>Last updated</td>
<td>{moment(lastUpdated + "Z").fromNow() || "Unknown"}</td>
</tr>
</tbody>
</HTMLTable>
<Divider />
@ -103,7 +109,7 @@ class SidebarImpl extends React.Component<ISidebarProps> {
private renderPeers = () => {
const peers = this.props.instanceDetails!.peers;
if (!peers) {
if (!peers || peers.length === 0) {
return;
}
const peerRows = peers.map(instance => (

View File

@ -4680,6 +4680,10 @@ mkdirp@0.5.x, mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@~0.5.0, mkdirp@~0.5.1:
dependencies:
minimist "0.0.8"
moment@^2.22.2:
version "2.22.2"
resolved "https://registry.yarnpkg.com/moment/-/moment-2.22.2.tgz#3c257f9839fc0e93ff53149632239eb90783ff66"
move-concurrently@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/move-concurrently/-/move-concurrently-1.0.1.tgz#be2c005fda32e0b29af1f05d7c4b33214c701f92"

View File

@ -58,7 +58,7 @@ def get_key(data, keys: list):
def validate_int(integer):
return isinstance(integer, int) and 0 <= integer < 2147483647 or None
return integer if (isinstance(integer, int) and 0 <= integer < 2147483647) else None
def log(text):