fix(traffic): считать общий пик по совпадающим интервалам
This commit is contained in:
1 parent
dbc3b2c947
commit
7b88416415
21 files changed
+1390
-27
No files matched your search
@@ -2,6 +2,7 @@ import { z } from "zod"
|
||||
const timestamp = z.string().refine(v => Number.isFinite(Date.parse(v))).nullable()
|
||||
const rate = z.number().finite().nonnegative().nullable()
|
||||
const meta = z.object({ rxNow: z.boolean(), txNow: z.boolean(), rxSeries: z.array(z.boolean()), txSeries: z.array(z.boolean()),
|
||||
rxPeak: z.boolean().optional(), txPeak: z.boolean().optional(),
|
||||
sampledAt: timestamp, expiresAt: timestamp.optional(), lastAttemptAt: timestamp.optional(), lastSucceededAt: timestamp.optional(), error: z.string().nullable().optional(),
|
||||
currentState: z.enum(["current", "unknown", "pending", "error", "stale", "disabled"]).optional() })
|
||||
export type TrafficObservationMeta = z.infer<typeof meta>
|
||||
@@ -19,7 +20,7 @@ export function projectTrafficObservations(raw: unknown, now = Date.now()) {
|
||||
const rxSeries = r.rxSeries.map((v, i) => o?.rxSeries[i] ? v : null)
|
||||
const txSeries = r.txSeries.map((v, i) => o?.txSeries[i] ? v : null)
|
||||
return { observations: o, volumeUnit: r.volumeUnit, rxNow: current && o?.rxNow ? r.rxNow : null, txNow: current && o?.txNow ? r.txNow : null,
|
||||
rxSeries, txSeries, rxPeak: rxSeries.some(v => v !== null) ? r.rxPeak : null,
|
||||
txPeak: txSeries.some(v => v !== null) ? r.txPeak : null,
|
||||
rxSeries, txSeries, rxPeak: (o?.rxPeak ?? rxSeries.some(v => v !== null)) ? r.rxPeak : null,
|
||||
txPeak: (o?.txPeak ?? txSeries.some(v => v !== null)) ? r.txPeak : null,
|
||||
rxTotal: r.volumeUnit && rxSeries.some(v => v !== null) ? r.rxTotal : null, txTotal: r.volumeUnit && txSeries.some(v => v !== null) ? r.txTotal : null }
|
||||
}
|
||||
Reference in new issue
Block a user