Skip to content

Commit 7b90294

Browse files
committed
eng-1352 replace UUIDv4 by UUIDv7, which indexes better
1 parent 6e31930 commit 7b90294

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

apps/obsidian/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"tslib": "2.5.1",
3535
"tsx": "^4.19.2",
3636
"typescript": "5.5.4",
37+
"uuidv7": "1.1.0",
3738
"zod": "^3.24.1"
3839
},
3940
"dependencies": {

apps/obsidian/src/utils/syncDgNodesToSupabase.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/* eslint-disable @typescript-eslint/naming-convention */
2+
import { uuidv7 } from "uuidv7";
23
import { Notice, TFile } from "obsidian";
34
import { DGSupabaseClient } from "@repo/database/lib/client";
45
import { Json } from "@repo/database/dbTypes";
@@ -101,7 +102,10 @@ const deleteNodesFromSupabase = async (
101102
if (conceptDeleteError) {
102103
result.success = false;
103104
result.errors.concept = conceptDeleteError;
104-
console.error("Failed to delete concepts from Supabase:", conceptDeleteError);
105+
console.error(
106+
"Failed to delete concepts from Supabase:",
107+
conceptDeleteError,
108+
);
105109
}
106110

107111
const { error: contentDeleteError } = await supabaseClient
@@ -152,7 +156,7 @@ const ensureNodeInstanceId = async (
152156
return existingId;
153157
}
154158

155-
const nodeInstanceId = crypto.randomUUID();
159+
const nodeInstanceId = uuidv7();
156160
await plugin.app.fileManager.processFrontMatter(file, (fm) => {
157161
(fm as Record<string, unknown>).nodeInstanceId = nodeInstanceId;
158162
});
@@ -195,7 +199,6 @@ const mergeChangeTypes = (
195199
return Array.from(merged);
196200
};
197201

198-
199202
/**
200203
* Step 1: Collect all discourse nodes from the vault
201204
* Filters markdown files that have nodeTypeId in frontmatter
@@ -635,10 +638,7 @@ export const syncSpecificFiles = async (
635638
const changeTypesByPath = new Map<string, ChangeType[]>();
636639
for (const filePath of filePaths) {
637640
const existing = changeTypesByPath.get(filePath) ?? [];
638-
changeTypesByPath.set(
639-
filePath,
640-
mergeChangeTypes(existing, ["content"]),
641-
);
641+
changeTypesByPath.set(filePath, mergeChangeTypes(existing, ["content"]));
642642
}
643643

644644
await syncDiscourseNodeChanges(plugin, changeTypesByPath);

pnpm-lock.yaml

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)