Yan Wang
revised dockerfile, package, server,app_new, and add api
0ea25d9
export type DataDict = Record<string, { date: string; close: number[] }[]>;
export async function apiGetLatestDataset() {
const r = await fetch("/api/dataset/latest");
if (!r.ok) throw new Error(await r.text());
return r.json();
}
export async function apiUpsertDataset(body: {
dataset_id: string;
name: string;
data: DataDict;
assets: string[];
dates: string[];
}) {
const r = await fetch("/api/dataset/upsert", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(body),
});
if (!r.ok) throw new Error(await r.text());
return r.json();
}
export async function apiGetAnnotation(dataset_id: string, user_id: string) {
const url = `/api/annotation/get?dataset_id=${dataset_id}&user_id=${user_id}`;
const r = await fetch(url);
if (!r.ok) throw new Error(await r.text());
return r.json();
}
export async function apiUpsertAnnotation(body: {
dataset_id: string;
user_id: string;
selections: any[];
step: number;
window_len: number;
}) {
const r = await fetch("/api/annotation/upsert", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(body),
});
if (!r.ok) throw new Error(await r.text());
return r.json();
}