Repository navigation
Migrate reviews to resource_edits table - #42
Merged
Merged
Conversation
Points the app at resource_edits (approve/reject/rollback RPCs, new-resource queue, review-queue views) instead of the throwaway resource_revisions table, and adds the missing UPDATE policy for authenticated reviewers editing PENDING rows before approval. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com> # Conflicts: # app/api/resource-revisions/methods.ts # app/routes/authenticated/dashboard.tsx # app/routes/authenticated/reviews/detail.tsx # app/routes/authenticated/reviews/index.tsx # app/types/ResourceRevision.ts # app/utils/chipColors.tsx
biome check flagged import ordering and formatting drift introduced while resolving the merge conflicts with main. Co-authored-by: Cursor <cursoragent@cursor.com>
This change optimizes dependency handling for the @mui/icons-material package by including it in the optimizeDeps configuration. This prevents file handle exhaustion during development, particularly in environments with additional overhead like OneDrive-synced folders.
This commit adds a new entry to .gitignore for local notes and deletes the now-unnecessary next-up.md file, which contained a working list of tasks.
RNR1
approved these changes
Aug 12, 2026
RNR1
left a comment
Contributor
There was a problem hiding this comment.
LGTM - these comments should be addressed as follow ups, except removing the what's next doc
| const editAPI = getResourceEditAPI(client); | ||
| const edits = await editAPI.getList(); | ||
|
|
||
| const submitterCounts = new Map<string, number>(); |
Contributor
There was a problem hiding this comment.
Ideally, we run aggregation queries on the database level instead of manipulating the data in code
Contributor
Author
There was a problem hiding this comment.
will fix in a future PR, have an issue to track this
| revisions.map((revision) => ({ | ||
| ...revision, | ||
| () => [ | ||
| ...edits.map((edit) => ({ |
Contributor
There was a problem hiding this comment.
same here - ideally the data is already prepped for usage by the time it gets here
Contributor
Author
There was a problem hiding this comment.
will fix in a future PR, have an issue to track this
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Migrate reviews to resource_edits (replaces broken partial rename on main)
Problem
The review dashboard (
/reviews,/reviews/:id, and the dashboard summary) was built againstresource_revisions, a throwaway staging table. The real table this app should build forward on isresource_edits(added in #24), which already ships theapprove_edit/reject_edit/rollback_to_editRPCs, a new-resource submission path (mapped_resource IS NULL), and ready-made review-queue views — none of whichresource_revisionshas.Separately,
mainpicked up a partial, incomplete rename toresource_editsas a side effect of an unrelated PR (#41). That version only renamed the table string and a couple of field names, but the underlying logic is still broken:statusinstead ofreview_status(the actual review-state column —statuson this table is just a mirrored copy of the resource's operational status). It also never calls the RPCs, so even a "successful" click never copies the proposed changes intoresources— nothing goes live on the map, and no error is shown to the reviewer.mapped_resource IS NULL) — these don't show up in the queue at all.reviewed_by/reviewed_at— that's why the dashboard's "Top approvers" card has been disabled with a placeholder tooltip.resource_editswas missing anUPDATEpolicy forauthenticatedreviewers, so edits made on the detail page before approval (the "Save changes" button) were silently dropped by RLS.Solution
app/api/resource-edits/methods.tsandapp/types/ResourceEdit.ts(clearly named after the table they wrap), replacingapp/api/resource-revisions/methods.tsandapp/types/ResourceRevision.ts(deleted)./reviewsnow merges the edit queue (resource_edits_queue) and new-resource queue (new_resources_queue) into one table, with a "Kind" (New/Edit) column./reviews/:idapprove/reject now call the realapprove_edit/reject_editRPCs (capturing the reviewer's email fromcontext.get(userContext)), so approving an edit actually applies it toresourcesand goes live on the map. Handles brand-new submissions without the "resource not found" warning.dashboard.tsxmigrated too; "Top approvers" is now live since the RPCs setreviewed_by.supabase/migrations/20260728000000_resource_edits_update_policy.sql, the missingUPDATEpolicy scoped toPENDINGrows forauthenticatedreviewers (approve/reject still must go through the RPCs — the policy'swith checkblocks flippingreview_statusdirectly).Manual step before/after merge: the RLS migration above hasn't been applied to the live Supabase DB yet — this repo only has the anon key, so it needs to be run via the Supabase SQL editor or CLI with an owner/service-role credential. Until then, "Save changes" on the detail page will still silently no-op.
Reference
Closes #34. Builds on the table/RPCs added in #24.
Screenshots
N/A — no visual/UI changes, this is a data-source swap behind the existing review UI.
Checklist