-
Notifications
You must be signed in to change notification settings - Fork 3
ENG-990 Use all pages query from supabase not using roam #521
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ENG-990 Use all pages query from supabase not using roam #521
Conversation
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
This stack of pull requests is managed by Graphite. Learn more about stacking. |
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
📝 WalkthroughWalkthroughThree utilities were updated to enhance node querying and data retrieval. The Roam query in getAllDiscourseNodesSince was rewritten to compute filterTime as the maximum of node create and edit times (with defaults), applying the since filter to this combined timestamp. The hyde utility was migrated from local Roam page UID retrieval to Supabase-backed getAllNodes calls. The getAllNodes function signature was extended with an optional ofTypes parameter to enable node-type filtering. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
Pre-merge checks❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
apps/roam/src/utils/hyde.ts (1)
465-482: Consider adding error handling for the Supabase query.The
getAllNodescall could throw if the Supabase request fails or if there are network issues. Wrapping this in a try-catch block would prevent unhandled exceptions from bubbling up and allow graceful fallback to an empty array.Apply this diff to add error handling:
+ try { candidateNodesForHyde = ( await getAllNodes({ supabase, spaceId, fields: { content: ["source_local_id", "text"] }, ofTypes: validTypes, pagination: { limit: 10000 }, }) ) .map((c) => { const node = findDiscourseNode(c.Content?.source_local_id || ""); return { uid: c.Content?.source_local_id || "", text: c.Content?.text || "", type: node ? node.type : "", }; }) .filter((n) => n.uid && n.text && n.type); + } catch (error) { + console.error("Failed to fetch nodes from Supabase:", error); + return []; + }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
apps/roam/src/utils/getAllDiscourseNodesSince.ts(1 hunks)apps/roam/src/utils/hyde.ts(2 hunks)packages/database/src/lib/queries.ts(2 hunks)
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: sid597
PR: DiscourseGraphs/discourse-graph#232
File: apps/roam/src/utils/getAllDiscourseNodesSince.ts:18-31
Timestamp: 2025-06-22T10:40:52.752Z
Learning: In apps/roam/src/utils/getAllDiscourseNodesSince.ts, the user confirmed that querying for `?title` with `:node/title` and mapping it to the `text` field in the DiscourseGraphContent type is the correct implementation for retrieving discourse node content from Roam Research, despite it appearing to query page titles rather than block text content.
📚 Learning: 2025-06-22T10:40:52.752Z
Learnt from: sid597
PR: DiscourseGraphs/discourse-graph#232
File: apps/roam/src/utils/getAllDiscourseNodesSince.ts:18-31
Timestamp: 2025-06-22T10:40:52.752Z
Learning: In apps/roam/src/utils/getAllDiscourseNodesSince.ts, the user confirmed that querying for `?title` with `:node/title` and mapping it to the `text` field in the DiscourseGraphContent type is the correct implementation for retrieving discourse node content from Roam Research, despite it appearing to query page titles rather than block text content.
Applied to files:
apps/roam/src/utils/getAllDiscourseNodesSince.ts
📚 Learning: 2025-06-22T10:40:21.679Z
Learnt from: sid597
PR: DiscourseGraphs/discourse-graph#232
File: apps/roam/src/utils/getAllDiscourseNodesSince.ts:15-16
Timestamp: 2025-06-22T10:40:21.679Z
Learning: In the getAllDiscourseNodesSince function in apps/roam/src/utils/getAllDiscourseNodesSince.ts, date validation is performed before the function is called, so additional date validation within the function is not needed.
Applied to files:
apps/roam/src/utils/getAllDiscourseNodesSince.ts
🔇 Additional comments (5)
apps/roam/src/utils/getAllDiscourseNodesSince.ts (1)
79-92: Query logic correctly implements "last modified" filtering.The dual
get-elsepattern on lines 89-90 correctly handles nodes that may not have an:edit/time:
nodeEditTime(line 89) captures the actual edit time or 0 for the result payloadfilterTime(line 90) uses edit time if present, otherwise falls back to create time for filteringThis ensures the
sincefilter applies to whichever timestamp is more recent or available.Based on learnings.
apps/roam/src/utils/hyde.ts (2)
459-463: LGTM: Proper null guards for Supabase client and context.The early returns prevent downstream null/undefined errors and gracefully degrade to empty results when the Supabase context or client is unavailable.
475-475: Remove this review comment -findDiscourseNodealready handles empty string correctly.The function explicitly accepts empty string as a default parameter and is designed to handle this case. When an empty uid is passed, it attempts to find a matching node and returns either the node or
false—both handled gracefully by the optional chaining (node?.type) at the call site. No changes needed.Likely an incorrect or invalid review comment.
packages/database/src/lib/queries.ts (2)
328-328: Cosmetic quote style change.Changed single quotes to double quotes for consistency. No functional impact.
598-620: LGTM: Clean API extension for type filtering.The
ofTypesparameter is properly added as optional, maintains backward compatibility, and follows the established pattern used in other query functions likegetNodesByType. The parameter is correctly propagated togetConceptsvia the scope object.
mdroidian
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not adjust getAllNodes unless we are absolutely sure it is necessary.

Summary by CodeRabbit