From 4d01ffbc86c60663cad6dfc7cdfe058a3c153fc9 Mon Sep 17 00:00:00 2001 From: Jared Pereira Date: Thu, 8 Jun 2023 15:29:45 -0400 Subject: [PATCH] sync local names to supabase --- .../routes/update_space_data.ts | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/backend/SpaceDurableObject/routes/update_space_data.ts b/backend/SpaceDurableObject/routes/update_space_data.ts index 8d7c0aef..7dce002e 100644 --- a/backend/SpaceDurableObject/routes/update_space_data.ts +++ b/backend/SpaceDurableObject/routes/update_space_data.ts @@ -40,6 +40,25 @@ export const update_space_data_route = makeRoute({ env.env.SUPABASE_URL, env.env.SUPABASE_API_TOKEN ); + + let spaceNames = await env.factStore.scanIndex.aev( + "space/local-unique-name" + ); + for (let spaceName of spaceNames) { + let spaceID = await env.factStore.scanIndex.eav( + spaceName.entity, + "space/id" + ); + if (spaceID) { + await supabase + .from("space_data") + .update({ + name: spaceName.value, + }) + .eq("do_id", spaceID.value); + } + } + if (!owner || !data["space/display_name"]) return { data: { success: false } }; @@ -60,7 +79,6 @@ export const update_space_data_route = makeRoute({ await supabase .from("space_data") .update({ - name: data["space/name"], image: data["space/door/uploaded-image"]?.filetype === "image" ? data["space/door/uploaded-image"]?.id