refine the dashboard

This commit is contained in:
yoan
2025-01-12 19:55:40 +08:00
parent 9839e2bb60
commit 503d9c34f8
5 changed files with 218 additions and 6 deletions

View File

@@ -5,20 +5,29 @@ import { getPocketBase } from "./pocketbase";
const COLLECTION_NAME = "workflow_run";
export type ListWorkflowRunsRequest = {
workflowId: string;
workflowId?: string;
page?: number;
perPage?: number;
expand?: boolean;
};
export const list = async (request: ListWorkflowRunsRequest) => {
const page = request.page || 1;
const perPage = request.perPage || 10;
console.log("request.workflowId", request.workflowId);
let filter = "";
const params: Record<string, string> = {};
if (request.workflowId) {
filter = `workflowId={:workflowId}`;
params.workflowId = request.workflowId;
}
return await getPocketBase()
.collection(COLLECTION_NAME)
.getList<WorkflowRunModel>(page, perPage, {
filter: getPocketBase().filter("workflowId={:workflowId}", { workflowId: request.workflowId }),
filter: getPocketBase().filter(filter, params),
sort: "-created",
requestKey: null,
expand: request.expand ? "workflowId" : undefined,
});
};