Skip to content

Commit

Permalink
src/lib/paddles.ts: allow machine_type filter for useRuns
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
VallariAg committed Nov 15, 2024
1 parent a0cc198 commit 9d6cacc
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/lib/paddles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,19 @@ function getURL(endpoint: string, params?: GetURLParams) {
}

function useRuns(params: GetURLParams): UseQueryResult<Run[]> {
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) => {
Expand Down

0 comments on commit 9d6cacc

Please sign in to comment.