Show telemetry history within repeater view on load

This commit is contained in:
Jack Kingsman
2026-04-01 19:35:55 -07:00
parent 1d4e25d97c
commit 2bef62dd87
3 changed files with 16 additions and 1 deletions
+11
View File
@@ -153,6 +153,17 @@ async def repeater_status(public_key: str) -> RepeaterStatusResponse:
return response
@router.get("/{public_key}/repeater/telemetry-history")
async def repeater_telemetry_history(public_key: str) -> list[TelemetryHistoryEntry]:
"""Return stored telemetry history for a repeater (no radio command needed)."""
contact = await _resolve_contact_or_404(public_key)
_require_repeater(contact)
since = int(time.time()) - 30 * 86400
rows = await RepeaterTelemetryRepository.get_history(contact.public_key, since)
return [TelemetryHistoryEntry(**row) for row in rows]
@router.post("/{public_key}/repeater/lpp-telemetry", response_model=RepeaterLppTelemetryResponse)
async def repeater_lpp_telemetry(public_key: str) -> RepeaterLppTelemetryResponse:
"""Fetch CayenneLPP sensor telemetry from a repeater (single attempt, 10s timeout)."""
+3
View File
@@ -35,6 +35,7 @@ import type {
RepeaterRadioSettingsResponse,
RepeaterStatusResponse,
StatisticsResponse,
TelemetryHistoryEntry,
TraceResponse,
UnreadCounts,
} from './types';
@@ -374,6 +375,8 @@ export const api = {
fetchJson<RepeaterStatusResponse>(`/contacts/${publicKey}/repeater/status`, {
method: 'POST',
}),
repeaterTelemetryHistory: (publicKey: string) =>
fetchJson<TelemetryHistoryEntry[]>(`/contacts/${publicKey}/repeater/telemetry-history`),
repeaterNeighbors: (publicKey: string) =>
fetchJson<RepeaterNeighborsResponse>(`/contacts/${publicKey}/repeater/neighbors`, {
method: 'POST',
+2 -1
View File
@@ -51,10 +51,11 @@ vi.mock('../hooks/useRepeaterDashboard', () => ({
useRepeaterDashboard: () => mockHook,
}));
// Mock api module (used by routing override tests)
// Mock api module (used by routing override tests + telemetry history fetch on mount)
vi.mock('../api', () => ({
api: {
setContactRoutingOverride: vi.fn().mockResolvedValue({ status: 'ok' }),
repeaterTelemetryHistory: vi.fn().mockResolvedValue([]),
},
}));