Skip to content

Commit dcb1ff6

Browse files
move lastEvaluatedAt to the polling query so the chart window advances
1 parent 9292654 commit dcb1ff6

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

packages/web/app/src/pages/target-alerts-detail.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ const TargetAlertsDetailPage_RuleConfigQuery = graphql(`
6262
thresholdValue
6363
direction
6464
confirmationMinutes
65-
lastEvaluatedAt
6665
channels {
6766
id
6867
name
@@ -122,6 +121,7 @@ const TargetAlertsDetailPage_StateLogQuery = graphql(`
122121
id
123122
metricAlertRule(id: $ruleId) {
124123
id
124+
lastEvaluatedAt
125125
stateAt(timestamp: $from)
126126
stateLog(from: $from, to: $to) {
127127
id
@@ -300,7 +300,6 @@ function RuleStateLogSection(props: {
300300
createdAt: string;
301301
metric?: MetricAlertRuleMetric | null;
302302
severity: MetricAlertRuleSeverity;
303-
lastEvaluatedAt?: string | null;
304303
};
305304
}) {
306305
const { organizationSlug, projectSlug, targetSlug, ruleId, viewRangeMinutes, rule } = props;
@@ -325,6 +324,9 @@ function RuleStateLogSection(props: {
325324
const data = useKeepPreviousData(result.data, result.fetching || result.stale);
326325
const stateLog = data?.target?.metricAlertRule?.stateLog ?? [];
327326
const stateAtWindowStart = data?.target?.metricAlertRule?.stateAt;
327+
// Read from the polling query, not the rule config: the chart's scored window
328+
// has to advance with each evaluation, and the config query never refetches.
329+
const lastEvaluatedAt = data?.target?.metricAlertRule?.lastEvaluatedAt;
328330
const operationsStats = data?.target?.operationsStats ?? null;
329331
const hasNoData = !data;
330332
const stateLogStatus =
@@ -371,7 +373,7 @@ function RuleStateLogSection(props: {
371373
direction={rule.direction}
372374
thresholdType={rule.thresholdType}
373375
timeWindowMinutes={rule.timeWindowMinutes}
374-
evaluatedAt={rule.lastEvaluatedAt}
376+
evaluatedAt={lastEvaluatedAt}
375377
/>
376378
</section>
377379

0 commit comments

Comments
 (0)