From 9d6cacc5839ce98ed940188df1bc31e2ac881887 Mon Sep 17 00:00:00 2001 From: Vallari Agrawal Date: Fri, 15 Nov 2024 15:24:02 +0530 Subject: [PATCH] src/lib/paddles.ts: allow machine_type filter for useRuns This is to handle difference in machine_type filter in two endpoints /node/?machine_type=xyz and /runs/machine_type/xyz Fixes machine_type filter for RunList. Signed-off-by: Vallari Agrawal --- src/lib/paddles.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/lib/paddles.ts b/src/lib/paddles.ts index 905b79d..321e3f1 100644 --- a/src/lib/paddles.ts +++ b/src/lib/paddles.ts @@ -54,12 +54,19 @@ function getURL(endpoint: string, params?: GetURLParams) { } function useRuns(params: GetURLParams): UseQueryResult { + let baseUrl = "/runs/"; const params_ = { ...params }; if (params_.pageSize) { params_.count = params.pageSize; delete params_.pageSize; } - const url = getURL("/runs/", params); + if (params_.machine_type) { + // this is to handle difference in machine_type filter + // in two endpoints /node/?machine_type=xyz and /runs/machine_type/xyz + baseUrl += "machine_type/" + params_.machine_type + "/"; + delete params_.machine_type; + } + const url = getURL(baseUrl, params); const query = useQuery(["runs", { url }], { select: (data: Run[]) => data.map((item) => {