From 9dcd49961a9fbd492f147358918421aa04f53e1c Mon Sep 17 00:00:00 2001 From: Allan Hvam Date: Mon, 19 Aug 2024 14:29:57 +0200 Subject: [PATCH] fix: set default workspace samples to empty list --- app/src/app/workspaces/create-workspace.tsx | 2 +- web/src/SAP/src/repositories/workspaces.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/app/workspaces/create-workspace.tsx b/app/src/app/workspaces/create-workspace.tsx index 60a21e5f..e9aabe22 100644 --- a/app/src/app/workspaces/create-workspace.tsx +++ b/app/src/app/workspaces/create-workspace.tsx @@ -12,7 +12,7 @@ export function CreateWorkspace() { const [ createWorkspaceQueryState, createWorkspaceMutation, - ] = useMutation((name: string) => createWorkspace({ name })); + ] = useMutation((name: string) => createWorkspace({ name, samples: [] })); const [needsNotify, setNeedsNotify] = useState(true); diff --git a/web/src/SAP/src/repositories/workspaces.py b/web/src/SAP/src/repositories/workspaces.py index 5f8e3429..4ef5e21f 100644 --- a/web/src/SAP/src/repositories/workspaces.py +++ b/web/src/SAP/src/repositories/workspaces.py @@ -62,6 +62,10 @@ def create_workspace(user: str, workspace: CreateWorkspace): conn = get_connection() db = conn[DB_NAME] workspaces = db[WORKSPACES_COL_NAME] + + if workspace.samples is None: + workspace.samples = [] + record = {**workspace.to_dict(), "created_by": user} return workspaces.update_one({'created_by': user, 'name': workspace.name}, {"$set": record}, upsert=True)