18 lines
1.2 KiB
TypeScript
18 lines
1.2 KiB
TypeScript
import { speedHistoryRunSchema } from "@mmapp/contracts"
|
|
export type StoredSpeedRun = {
|
|
id:string;probeId:string|null;srcServerId:number;dstServerId:number;srcInterface:string|null;dstInterface:string|null;
|
|
srcAddress:string|null;dstAddress:string|null;srcInterfaceAddress:string|null;dstInterfaceAddress:string|null;
|
|
protocol:string;direction:string;durationSec:number;txAvgMbps:number|null;rxAvgMbps:number|null;
|
|
pingRttMs:number|null;pingLossPct:number|null;pingError:string|null;status:string;error:string|null;createdAt:string;
|
|
}
|
|
export function mapSpeedHistoryRun(row:StoredSpeedRun) {
|
|
return speedHistoryRunSchema.parse({
|
|
id:row.id,probeId:row.probeId,srcServerId:String(row.srcServerId),dstServerId:String(row.dstServerId),
|
|
srcInterface:row.srcInterface ?? "",dstInterface:row.dstInterface ?? "",
|
|
srcAddress:row.srcAddress,dstAddress:row.dstAddress,srcInterfaceAddress:row.srcInterfaceAddress,dstInterfaceAddress:row.dstInterfaceAddress,
|
|
protocol:row.protocol,direction:row.direction,durationSec:row.durationSec,
|
|
txAvgMbps:row.txAvgMbps,rxAvgMbps:row.rxAvgMbps,status:row.status,error:row.error,createdAt:new Date(row.createdAt).toISOString(),
|
|
afterBtPing:{rttMs:row.pingRttMs,lossPct:row.pingLossPct,error:row.pingError},
|
|
})
|
|
}
|