Skip to content

Commit 9d6cacc

Browse files
committed
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 <[email protected]>
1 parent a0cc198 commit 9d6cacc

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/lib/paddles.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,19 @@ function getURL(endpoint: string, params?: GetURLParams) {
5454
}
5555

5656
function useRuns(params: GetURLParams): UseQueryResult<Run[]> {
57+
let baseUrl = "/runs/";
5758
const params_ = { ...params };
5859
if (params_.pageSize) {
5960
params_.count = params.pageSize;
6061
delete params_.pageSize;
6162
}
62-
const url = getURL("/runs/", params);
63+
if (params_.machine_type) {
64+
// this is to handle difference in machine_type filter
65+
// in two endpoints /node/?machine_type=xyz and /runs/machine_type/xyz
66+
baseUrl += "machine_type/" + params_.machine_type + "/";
67+
delete params_.machine_type;
68+
}
69+
const url = getURL(baseUrl, params);
6370
const query = useQuery(["runs", { url }], {
6471
select: (data: Run[]) =>
6572
data.map((item) => {

0 commit comments

Comments
 (0)