Skip to content

Commit

Permalink
sync local names to supabase
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredpereira committed Jun 8, 2023
1 parent c6d994f commit 4d01ffb
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion backend/SpaceDurableObject/routes/update_space_data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 } };

Expand All @@ -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
Expand Down

1 comment on commit 4d01ffb

@vercel
Copy link

@vercel vercel bot commented on 4d01ffb Jun 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.