Skip to content

Commit 6dc6946

Browse files
jdonelsonclaude
andcommitted
console: freshness review nits
Stop exporting rankFromWorst and replace the two unreachable stats fallbacks with one EMPTY_STATS. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 86dfc27 commit 6dc6946

2 files changed

Lines changed: 15 additions & 5 deletions

File tree

‎console/src/api/materialize/freshness/lagHistory.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ export const LAG_PERCENTILES = { p90: 0.9, p99: 0.99, p99_9: 0.999 } as const;
144144
* The nearest-rank position of percentile `p` among `n` readings, counted from
145145
* the worst, which is 1. Matches the pick the percentile queries make in SQL.
146146
*/
147-
export function rankFromWorst(p: number, n: number) {
147+
function rankFromWorst(p: number, n: number) {
148148
return n - Math.ceil(p * n) + 1;
149149
}
150150

‎console/src/platform/freshness/freshnessRows.ts‎

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,18 @@ export const lagOrUnreadable = (lag: number | null) =>
139139
const currentFrom = (latest: number | null | undefined) =>
140140
latest === undefined ? null : lagOrUnreadable(latest);
141141

142+
/**
143+
* The stats of an object with no readings, for a line missing from
144+
* `statsByKey`. The callers build both from the same lines, so none is.
145+
*/
146+
const EMPTY_STATS: ObjectStats = {
147+
current: null,
148+
peak: null,
149+
p90: null,
150+
p99: null,
151+
p99_9: null,
152+
};
153+
142154
const statFor = (stats: ObjectStats, predicate: Predicate) =>
143155
predicate === "current"
144156
? stats.current
@@ -164,8 +176,7 @@ export function judgeLines(
164176
statsByKey: Map<string, ObjectStats>,
165177
): ThresholdLineSeries<DataPoint>[] {
166178
return lines.map((line) => {
167-
const stats =
168-
statsByKey.get(line.key) ?? computeStats(undefined, undefined);
179+
const stats = statsByKey.get(line.key) ?? EMPTY_STATS;
169180
return {
170181
key: line.key,
171182
label: line.label,
@@ -213,8 +224,7 @@ export function buildFreshnessRows({
213224

214225
return judged
215226
.map((line) => {
216-
const stats =
217-
statsByKey.get(line.key) ?? computeStats(undefined, undefined);
227+
const stats = statsByKey.get(line.key) ?? EMPTY_STATS;
218228
const object = objectsById.get(line.key);
219229
const hydration = hydrationByObjectId.get(line.key);
220230
// Inclusive, matching `isBreaching` on the graph and the Objects page's

0 commit comments

Comments
 (0)