MCPcopy Index your code
hub / github.com/coder/coder / infiniteWorkspaceBuilds

Function infiniteWorkspaceBuilds

site/src/api/queries/workspaceBuilds.ts:42–67  ·  view source on GitHub ↗
(
	workspaceId: string,
	req?: WorkspaceBuildsRequest,
)

Source from the content-addressed store, hash-verified

40];
41
42export const infiniteWorkspaceBuilds = (
43 workspaceId: string,
44 req?: WorkspaceBuildsRequest,
45) => {
46 const limit = req?.limit ?? 25;
47
48 return {
49 queryKey: [...workspaceBuildsKey(workspaceId), req],
50 getNextPageParam: (lastPage, pages) => {
51 if (lastPage.length < limit) {
52 return undefined;
53 }
54 return pages.length + 1;
55 },
56 initialPageParam: 0,
57 queryFn: ({ pageParam }) => {
58 if (typeof pageParam !== "number") {
59 throw new Error("pageParam must be a number");
60 }
61 return API.getWorkspaceBuilds(workspaceId, {
62 limit,
63 offset: pageParam <= 0 ? 0 : (pageParam - 1) * limit,
64 });
65 },
66 } satisfies UseInfiniteQueryOptions<WorkspaceBuild[]>;
67};
68
69function workspaceBuildLogsKey(workspaceBuildId: string) {
70 return ["workspaceBuilds", workspaceBuildId, "logs"] as const;

Callers 1

HistorySidebarFunction · 0.90

Calls 1

workspaceBuildsKeyFunction · 0.85

Tested by

no test coverage detected