Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions frontend/src/lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,17 @@ export interface ProposalResponse {
branch: string;
}

export interface BuildResponse {
status: string;
}

export interface DryRunBuildResponse {
dataset_name: string;
dataset_version: string;
dry_run: boolean;
rows: DataRow[];
}

export async function fetchDatasets(): Promise<DatasetSummary[]> {
const body = await apiFetch<{ datasets: DatasetSummary[] }>("/datasets");
return body.datasets;
Expand All @@ -134,6 +145,40 @@ export function fetchData(
);
}

// real build: builds missing timestamps in [start, end] and writes them to the
// db. synchronous server-side, so this can take a while for large ranges
export function triggerBuild(
name: string,
version: string,
start: string,
end: string,
): Promise<BuildResponse> {
return apiFetch<BuildResponse>(
`/build/${encodeURIComponent(name)}/${encodeURIComponent(version)}`,
{
method: "POST",
params: { start, end },
},
);
}

// dry run: rebuilds the whole dependency graph in-memory and returns the
// produced rows; nothing is written to the db
export function dryRunBuild(
name: string,
version: string,
start: string,
end: string,
): Promise<DryRunBuildResponse> {
return apiFetch<DryRunBuildResponse>(
`/build/${encodeURIComponent(name)}/${encodeURIComponent(version)}`,
{
method: "POST",
params: { start, end, "dry-run": "true" },
},
);
}

// nothing is written to the server: the backend validates the submission and
// opens a github pr; the dataset goes live after review + merge + restart
export function proposeDataset(
Expand Down
Loading