From 583ac7b2274c58d8348e5e3efb10a796e8faaf35 Mon Sep 17 00:00:00 2001 From: Vallari Agrawal Date: Fri, 14 Jun 2024 10:34:58 +0530 Subject: [PATCH 1/2] paddles.d.ts: Add 'RunWithJobs' interface Do not process jobs when loading RunList. This might improve the load time of run page. Only need to process jobs for 'useRun' query for JobList. Signed-off-by: Vallari Agrawal --- src/lib/paddles.d.ts | 6 +++++- src/lib/paddles.ts | 7 ++++--- src/pages/Run/index.tsx | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/lib/paddles.d.ts b/src/lib/paddles.d.ts index 381de57..412119c 100644 --- a/src/lib/paddles.d.ts +++ b/src/lib/paddles.d.ts @@ -64,7 +64,6 @@ export type Run = { name: string; branch: string; suite: string; - jobs: Job[]; scheduled: string; user: string; started: string; @@ -78,6 +77,11 @@ export type Run = { status: RunStatus; }; + +interface RunWithJobs extends Run { + jobs: Job[]; +} + export type Node = { name: string; description: string | null; diff --git a/src/lib/paddles.ts b/src/lib/paddles.ts index 905b79d..1f0b9eb 100644 --- a/src/lib/paddles.ts +++ b/src/lib/paddles.ts @@ -4,6 +4,7 @@ import type { UseQueryResult } from "@tanstack/react-query"; import type { GetURLParams, Run, Job, + RunWithJobs, Node, NodeJobs, StatsLocksResponse, StatsJobsResponse, @@ -69,10 +70,10 @@ function useRuns(params: GetURLParams): UseQueryResult { return query; } -function useRun(name: string): UseQueryResult { +function useRun(name: string): UseQueryResult { const url = getURL(`/runs/${name}/`); - const query = useQuery(["run", { url }], { - select: (data: Run) => { + const query = useQuery(["run", { url }], { + select: (data: RunWithJobs) => { data.jobs.forEach((item) => { item.id = item.job_id + ""; }); diff --git a/src/pages/Run/index.tsx b/src/pages/Run/index.tsx index a71382c..fcc8119 100644 --- a/src/pages/Run/index.tsx +++ b/src/pages/Run/index.tsx @@ -6,7 +6,7 @@ import Typography from "@mui/material/Typography"; import { format } from "date-fns"; import { Helmet } from "react-helmet"; -import type { Run as Run_, RunParams } from "../../lib/paddles.d"; +import type { RunWithJobs as Run_, RunParams } from "../../lib/paddles.d"; import { useRun } from "../../lib/paddles"; import JobList from "../../components/JobList"; From 9c7543bb342616e03a898d156e68ed123a194ee8 Mon Sep 17 00:00:00 2001 From: Vallari Agrawal Date: Fri, 14 Jun 2024 12:37:11 +0530 Subject: [PATCH 2/2] components/RunList: Disable `showColumnFilters` in initial state Signed-off-by: Vallari Agrawal --- src/components/RunList/index.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/RunList/index.tsx b/src/components/RunList/index.tsx index 1d09428..15578e9 100644 --- a/src/components/RunList/index.tsx +++ b/src/components/RunList/index.tsx @@ -247,6 +247,7 @@ export default function RunList(props: RunListProps) { desc: true, }, ], + showColumnFilters: false, }, state: { columnFilters,