Skip to content

Commit 48105c0

Browse files
fix(ui-v2): use expected_start_time for dashboard flow runs filtering (#21418)
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Alexander Streed <ajstreed1@gmail.com> Co-authored-by: Alexander Streed <alex.s@prefect.io>
1 parent 947bf12 commit 48105c0

File tree

10 files changed

+37
-32
lines changed

10 files changed

+37
-32
lines changed

ui-v2/src/components/dashboard/flow-runs-accordion/flow-runs-accordion-content.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export function FlowRunsAccordionContent({
4848
},
4949
page: targetPage,
5050
limit: ITEMS_PER_PAGE,
51-
sort: "START_TIME_DESC" as const,
51+
sort: "EXPECTED_START_TIME_DESC" as const,
5252
};
5353
},
5454
[filter, flowId],

ui-v2/src/components/dashboard/flow-runs-accordion/flow-runs-accordion-header.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export function FlowRunsAccordionHeader({
4343
const lastFlowRunFilter: FlowRunsFilter = useMemo(() => {
4444
return {
4545
...flowFilter,
46-
sort: "START_TIME_DESC",
46+
sort: "EXPECTED_START_TIME_DESC",
4747
limit: 1,
4848
offset: 0,
4949
};
@@ -63,9 +63,14 @@ export function FlowRunsAccordionHeader({
6363
className="text-sm font-medium text-foreground hover:underline flex items-center gap-1"
6464
onClick={(e) => e.stopPropagation()}
6565
/>
66-
{lastFlowRun?.start_time && (
66+
{(lastFlowRun?.start_time ?? lastFlowRun?.expected_start_time) && (
6767
<FormattedDate
68-
date={new Date(lastFlowRun.start_time)}
68+
date={
69+
new Date(
70+
(lastFlowRun?.start_time ??
71+
lastFlowRun?.expected_start_time) as string,
72+
)
73+
}
6974
format="relative"
7075
className="text-xs text-muted-foreground"
7176
/>

ui-v2/src/components/dashboard/flow-runs-accordion/flow-runs-accordion.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ describe("FlowRunsAccordionHeader", () => {
256256
render(
257257
<FlowRunsAccordionHeaderRouter
258258
flow={flow}
259-
filter={{ sort: "START_TIME_DESC", offset: 0 }}
259+
filter={{ sort: "EXPECTED_START_TIME_DESC", offset: 0 }}
260260
/>,
261261
{
262262
wrapper: createWrapper(),
@@ -285,7 +285,7 @@ describe("FlowRunsAccordionHeader", () => {
285285
render(
286286
<FlowRunsAccordionHeaderRouter
287287
flow={flow}
288-
filter={{ sort: "START_TIME_DESC", offset: 0 }}
288+
filter={{ sort: "EXPECTED_START_TIME_DESC", offset: 0 }}
289289
/>,
290290
{
291291
wrapper: createWrapper(),
@@ -319,7 +319,7 @@ describe("FlowRunsAccordionHeader", () => {
319319
render(
320320
<FlowRunsAccordionHeaderRouter
321321
flow={flow}
322-
filter={{ sort: "START_TIME_DESC", offset: 0 }}
322+
filter={{ sort: "EXPECTED_START_TIME_DESC", offset: 0 }}
323323
/>,
324324
{
325325
wrapper: createWrapper(),

ui-v2/src/components/dashboard/flow-runs-accordion/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export function FlowRunsAccordion({
3434
// Build the flow runs filter with state type
3535
const flowRunsFilter: FlowRunsFilter = useMemo(() => {
3636
const baseFilter: FlowRunsFilter = {
37-
sort: "START_TIME_DESC",
37+
sort: "EXPECTED_START_TIME_DESC",
3838
offset: 0,
3939
...filter,
4040
};

ui-v2/src/components/dashboard/flow-runs-card/index.test.tsx

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ describe("FlowRunsCard", () => {
167167

168168
const queryClient = new QueryClient();
169169
const queryOptions = buildFilterFlowRunsQuery({
170-
sort: "START_TIME_DESC",
170+
sort: "EXPECTED_START_TIME_DESC",
171171
offset: 0,
172172
});
173173
queryClient.setQueryData(queryOptions.queryKey, [flowRun1, flowRun2]);
@@ -188,7 +188,7 @@ describe("FlowRunsCard", () => {
188188

189189
const queryClient = new QueryClient();
190190
const filter: FlowRunsFilter = {
191-
sort: "START_TIME_DESC",
191+
sort: "EXPECTED_START_TIME_DESC",
192192
offset: 0,
193193
};
194194
const queryOptions = buildFilterFlowRunsQuery(filter);
@@ -205,7 +205,7 @@ describe("FlowRunsCard", () => {
205205
it("does not display count when no flow runs exist", async () => {
206206
const queryClient = new QueryClient();
207207
const queryOptions = buildFilterFlowRunsQuery({
208-
sort: "START_TIME_DESC",
208+
sort: "EXPECTED_START_TIME_DESC",
209209
offset: 0,
210210
});
211211
queryClient.setQueryData(queryOptions.queryKey, []);
@@ -221,7 +221,7 @@ describe("FlowRunsCard", () => {
221221
it("shows chart and state tabs when no flow runs", async () => {
222222
const queryClient = new QueryClient();
223223
const queryOptions = buildFilterFlowRunsQuery({
224-
sort: "START_TIME_DESC",
224+
sort: "EXPECTED_START_TIME_DESC",
225225
offset: 0,
226226
});
227227
queryClient.setQueryData(queryOptions.queryKey, []);
@@ -241,7 +241,7 @@ describe("FlowRunsCard", () => {
241241

242242
const queryClient = new QueryClient();
243243
const filter: FlowRunsFilter = {
244-
sort: "START_TIME_DESC",
244+
sort: "EXPECTED_START_TIME_DESC",
245245
offset: 0,
246246
};
247247
const queryOptions = buildFilterFlowRunsQuery(filter);
@@ -271,11 +271,11 @@ describe("FlowRunsCard", () => {
271271

272272
const queryClient = new QueryClient();
273273
const filter: FlowRunsFilter = {
274-
sort: "START_TIME_DESC",
274+
sort: "EXPECTED_START_TIME_DESC",
275275
offset: 0,
276276
flow_runs: {
277277
operator: "and_",
278-
start_time: {
278+
expected_start_time: {
279279
after_: startDate,
280280
before_: endDate,
281281
},
@@ -310,7 +310,7 @@ describe("FlowRunsCard", () => {
310310

311311
const queryClient = new QueryClient();
312312
const filter: FlowRunsFilter = {
313-
sort: "START_TIME_DESC",
313+
sort: "EXPECTED_START_TIME_DESC",
314314
offset: 0,
315315
flow_runs: {
316316
operator: "and_",
@@ -348,7 +348,7 @@ describe("FlowRunsCard", () => {
348348

349349
const queryClient = new QueryClient();
350350
const filter: FlowRunsFilter = {
351-
sort: "START_TIME_DESC",
351+
sort: "EXPECTED_START_TIME_DESC",
352352
offset: 0,
353353
flow_runs: {
354354
operator: "and_",
@@ -390,11 +390,11 @@ describe("FlowRunsCard", () => {
390390

391391
const queryClient = new QueryClient();
392392
const filter: FlowRunsFilter = {
393-
sort: "START_TIME_DESC",
393+
sort: "EXPECTED_START_TIME_DESC",
394394
offset: 0,
395395
flow_runs: {
396396
operator: "and_",
397-
start_time: {
397+
expected_start_time: {
398398
after_: startDate,
399399
before_: endDate,
400400
},
@@ -434,7 +434,7 @@ describe("FlowRunsCard", () => {
434434

435435
const queryClient = new QueryClient();
436436
const filter: FlowRunsFilter = {
437-
sort: "START_TIME_DESC",
437+
sort: "EXPECTED_START_TIME_DESC",
438438
offset: 0,
439439
};
440440
const queryOptions = buildFilterFlowRunsQuery(filter);
@@ -466,7 +466,7 @@ describe("FlowRunsCard", () => {
466466

467467
const queryClient = new QueryClient();
468468
const filter: FlowRunsFilter = {
469-
sort: "START_TIME_DESC",
469+
sort: "EXPECTED_START_TIME_DESC",
470470
offset: 0,
471471
};
472472
const queryOptions = buildFilterFlowRunsQuery(filter);
@@ -492,7 +492,7 @@ describe("FlowRunsCard", () => {
492492

493493
const queryClient = new QueryClient();
494494
const filter: FlowRunsFilter = {
495-
sort: "START_TIME_DESC",
495+
sort: "EXPECTED_START_TIME_DESC",
496496
offset: 0,
497497
};
498498
const queryOptions = buildFilterFlowRunsQuery(filter);
@@ -516,7 +516,7 @@ describe("FlowRunsCard", () => {
516516

517517
const queryClient = new QueryClient();
518518
const filter: FlowRunsFilter = {
519-
sort: "START_TIME_DESC",
519+
sort: "EXPECTED_START_TIME_DESC",
520520
offset: 0,
521521
};
522522
const queryOptions = buildFilterFlowRunsQuery(filter);

ui-v2/src/components/dashboard/flow-runs-card/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export function FlowRunsCard({
6767

6868
const flowRunsFilter: FlowRunsFilter = useMemo(() => {
6969
const baseFilter: FlowRunsFilter = {
70-
sort: "START_TIME_DESC",
70+
sort: "EXPECTED_START_TIME_DESC",
7171
offset: 0,
7272
};
7373

@@ -76,7 +76,7 @@ export function FlowRunsCard({
7676
};
7777

7878
if (filter?.startDate && filter?.endDate) {
79-
flowRunsFilterObj.start_time = {
79+
flowRunsFilterObj.expected_start_time = {
8080
after_: filter.startDate,
8181
before_: filter.endDate,
8282
};

ui-v2/src/components/deployments/deployment-details-runs-tab.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ function useGetNextRun(deployment: Deployment) {
128128
});
129129

130130
return useMemo(() => {
131-
if (!data || !data[0]) {
131+
if (!data?.[0]) {
132132
return undefined;
133133
}
134134
return {

ui-v2/src/components/events/events-line-chart/events-line-chart.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ type EventsTooltipProps = {
1717
};
1818

1919
const EventsTooltipContent = ({ active, payload }: EventsTooltipProps) => {
20-
if (!active || !payload || !payload.length) return null;
20+
if (!active || !payload?.length) return null;
2121

2222
const firstPayloadItem = payload[0];
2323
const point = firstPayloadItem?.payload;

ui-v2/src/components/ui/flow-run-activity-bar-graph/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ FlowRunActivityBarChart.displayName = "FlowRunActivityBarChart";
293293
type FlowRunTooltipProps = Partial<TooltipContentProps<number, string>>;
294294

295295
const FlowRunTooltip = ({ payload, active }: FlowRunTooltipProps) => {
296-
if (!active || !payload || !payload.length) {
296+
if (!active || !payload?.length) {
297297
return null;
298298
}
299299
const firstPayloadItem = payload[0] as { payload?: unknown } | undefined;
@@ -306,7 +306,7 @@ const FlowRunTooltip = ({ payload, active }: FlowRunTooltipProps) => {
306306
return null;
307307
}
308308
const flowRun = nestedPayload.flowRun as EnrichedFlowRun;
309-
if (!flowRun || !flowRun.id) {
309+
if (!flowRun?.id) {
310310
return null;
311311
}
312312

ui-v2/src/routes/dashboard.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,15 +224,15 @@ function buildFlowRunsFilterFromSearch(
224224
const { tags, hideSubflows } = search;
225225

226226
const baseFilter: FlowRunsFilter = {
227-
sort: "START_TIME_DESC",
227+
sort: "EXPECTED_START_TIME_DESC",
228228
offset: 0,
229229
};
230230

231231
const flowRunsFilterObj: NonNullable<FlowRunsFilter["flow_runs"]> = {
232232
operator: "and_",
233233
};
234234

235-
flowRunsFilterObj.start_time = {
235+
flowRunsFilterObj.expected_start_time = {
236236
after_: from,
237237
before_: to,
238238
};
@@ -535,7 +535,7 @@ export const Route = createFileRoute("/dashboard")({
535535
// Prefetch last flow run for this flow (matches FlowRunsAccordionHeader.lastFlowRunFilter)
536536
const lastFlowRunFilter: FlowRunsFilter = {
537537
...flowFilter,
538-
sort: "START_TIME_DESC",
538+
sort: "EXPECTED_START_TIME_DESC",
539539
limit: 1,
540540
offset: 0,
541541
};

0 commit comments

Comments
 (0)