Tick service freshness age in dashboard
All checks were successful
deploy / deploy (push) Successful in 35s
All checks were successful
deploy / deploy (push) Successful in 35s
Proof: npm test; npm run operator-dashboard:build; PYTHONPATH=. python3 test/render_release_manifest_test.py; PYTHONPATH=. python3 test/repo_deployments_test.py Assumptions: Service freshness timestamps remain snapshot evidence from service state; the UI should show their advancing age rather than imply a refreshed service poll happened. Still fake: Service health snapshots are not a venue event stream; exact quote settlement still requires durable inventory movement and no submitted-only evidence is treated as a completed trade.
This commit is contained in:
parent
ddb360a34f
commit
b735a54515
2 changed files with 20 additions and 2 deletions
|
|
@ -1,8 +1,25 @@
|
||||||
|
import { useEffect, useState } from 'react';
|
||||||
|
|
||||||
import Pill from './Pill.jsx';
|
import Pill from './Pill.jsx';
|
||||||
import { formatAge, formatBoolean, formatTimestamp } from '../lib/format.js';
|
import { formatAge, formatAgeFromTimestamp, formatBoolean, formatTimestamp } from '../lib/format.js';
|
||||||
|
|
||||||
|
function useNow(intervalMs = 1000) {
|
||||||
|
const [now, setNow] = useState(() => Date.now());
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const timer = window.setInterval(() => setNow(Date.now()), intervalMs);
|
||||||
|
return () => window.clearInterval(timer);
|
||||||
|
}, [intervalMs]);
|
||||||
|
|
||||||
|
return now;
|
||||||
|
}
|
||||||
|
|
||||||
export default function ServiceCard({ service }) {
|
export default function ServiceCard({ service }) {
|
||||||
const healthLabel = service.health_label || service.health_status || (service.reachable ? 'online' : 'offline');
|
const healthLabel = service.health_label || service.health_status || (service.reachable ? 'online' : 'offline');
|
||||||
|
const now = useNow();
|
||||||
|
const freshnessAge = service.freshness_at
|
||||||
|
? formatAgeFromTimestamp(service.freshness_at, now)
|
||||||
|
: formatAge(service.freshness_age_ms);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="service-card">
|
<div className="service-card">
|
||||||
|
|
@ -14,7 +31,7 @@ export default function ServiceCard({ service }) {
|
||||||
<div>{`Reachable ${formatBoolean(service.reachable)}`}</div>
|
<div>{`Reachable ${formatBoolean(service.reachable)}`}</div>
|
||||||
<div>{`Paused ${formatBoolean(service.paused)}`}</div>
|
<div>{`Paused ${formatBoolean(service.paused)}`}</div>
|
||||||
<div>{`Armed ${formatBoolean(service.armed)}`}</div>
|
<div>{`Armed ${formatBoolean(service.armed)}`}</div>
|
||||||
<div>{`Freshness ${formatAge(service.freshness_age_ms)}${service.freshness_age_ms == null ? '' : ' ago'}`}</div>
|
<div>{`Freshness ${freshnessAge}${freshnessAge === 'Unavailable' ? '' : ' ago'}`}</div>
|
||||||
<div>{`Freshness at ${formatTimestamp(service.freshness_at)}`}</div>
|
<div>{`Freshness at ${formatTimestamp(service.freshness_at)}`}</div>
|
||||||
<div className="mono">{service.base_url}</div>
|
<div className="mono">{service.base_url}</div>
|
||||||
{service.last_error ? <div>{JSON.stringify(service.last_error)}</div> : null}
|
{service.last_error ? <div>{JSON.stringify(service.last_error)}</div> : null}
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ test('funds page no longer renders duplicate quote and submission tables', () =>
|
||||||
});
|
});
|
||||||
|
|
||||||
test('dashboard freshness surfaces show age and exact timestamp evidence', () => {
|
test('dashboard freshness surfaces show age and exact timestamp evidence', () => {
|
||||||
|
assert.match(serviceCardSource, /formatAgeFromTimestamp\(service\.freshness_at, now\)/);
|
||||||
assert.match(serviceCardSource, /formatTimestamp\(service\.freshness_at\)/);
|
assert.match(serviceCardSource, /formatTimestamp\(service\.freshness_at\)/);
|
||||||
assert.match(serviceCardSource, /Freshness at/);
|
assert.match(serviceCardSource, /Freshness at/);
|
||||||
assert.match(stylesSource, /\.quote-row-flash td/);
|
assert.match(stylesSource, /\.quote-row-flash td/);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue