Skip to content

Commit

Permalink
paddles.d.ts: Add 'RunWithJobs' interface
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
VallariAg committed Jun 14, 2024
1 parent 249a7b5 commit 583ac7b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
6 changes: 5 additions & 1 deletion src/lib/paddles.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ export type Run = {
name: string;
branch: string;
suite: string;
jobs: Job[];
scheduled: string;
user: string;
started: string;
Expand All @@ -78,6 +77,11 @@ export type Run = {
status: RunStatus;
};


interface RunWithJobs extends Run {
jobs: Job[];
}

export type Node = {
name: string;
description: string | null;
Expand Down
7 changes: 4 additions & 3 deletions src/lib/paddles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type { UseQueryResult } from "@tanstack/react-query";
import type {
GetURLParams,
Run, Job,
RunWithJobs,
Node, NodeJobs,
StatsLocksResponse,
StatsJobsResponse,
Expand Down Expand Up @@ -69,10 +70,10 @@ function useRuns(params: GetURLParams): UseQueryResult<Run[]> {
return query;
}

function useRun(name: string): UseQueryResult<Run> {
function useRun(name: string): UseQueryResult<RunWithJobs> {
const url = getURL(`/runs/${name}/`);
const query = useQuery<Run, Error>(["run", { url }], {
select: (data: Run) => {
const query = useQuery<RunWithJobs, Error>(["run", { url }], {
select: (data: RunWithJobs) => {
data.jobs.forEach((item) => {
item.id = item.job_id + "";
});
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Run/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down

0 comments on commit 583ac7b

Please sign in to comment.