Repository navigation
feat(store): org projects search skips soft-deleted rows - #1943
Conversation
The search reads policies, projects, and users through the live-row helpers. Frontier does not set deleted_at on policies yet, so results do not change today.
…-deleted rows Seeds a soft-deleted project, a project whose only policy is soft-deleted, a soft-deleted user, and a soft-deleted policy, then checks the listing and the member counts. Brings in the shared SQL runners.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: raystack/frontier/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review. 📝 SummarySummary by CodeRabbit
WalkthroughThe org-project query now excludes soft-deleted policies, projects, and users. Unit SQL expectations and a PostgreSQL integration suite verify filtering and live membership counts. ChangesOrg-project live-row filtering
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~12 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to The updated filtering behavior is covered by the supplied repository and PostgreSQL test evidence; no merge-blocking risk remains. 🚥 Pre-merge checks | ✅ 2✅ 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 |
Coverage Report for CI Build 35852502356Warning Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes. Coverage increased (+0.9%) to 51.641%Details
Uncovered ChangesNo uncovered changes found. Coverage Regressions90 previously-covered lines in 7 files lost coverage.
Coverage Stats
💛 - Coveralls |
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository: raystack/frontier/.coderabbit.yaml
Review profile: CHILL
Plan: Advanced
Run ID: 98da7162-96e6-423f-910e-6e345ce4be4d
📒 Files selected for processing (4)
internal/store/postgres/org_projects_repository.gointernal/store/postgres/org_projects_repository_pg_test.gointernal/store/postgres/org_projects_repository_test.gointernal/store/postgres/postgres_test.go
Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review.
The org filter and both live filters go to a single Where call. The generated SQL is unchanged.
… missing The case filters by name and requires one row, instead of asserting inside a loop that runs zero times when the project is absent.
Second of the org view repositories. Follows #1939.
Summary
The org projects search leaves out soft-deleted policies, projects, and users. The member count and the user ids count live rows only.
Changes
fromLive(policies)and addslive(projects)andlive(users).org_projects_repository_pg_test.go: seeds a soft-deleted project, a project whose only policy is soft-deleted, a soft-deleted user, and a soft-deleted policy, then checks the listing and the member counts.postgres_test.gogains the sharedexecSQLandscalarSQLrunners. They are the same helpers as in feat(store): org users search skips soft-deleted rows #1939, copied so both branches merge cleanly. The copy goes away on rebase once feat(store): org users search skips soft-deleted rows #1939 lands.Technical Details
The search had no soft-delete filter at all. The joins are inner, so a project with no live policy drops out of the listing, the same way a project with no policies is absent today.
Frontier does not set
deleted_aton policies yet, so the listing returns the same rows as before.Test Plan
go test -run 'TestOrgProjectsRepository' ./internal/store/postgres/passes (unit tests and the new suite)maingolangci-lint run ./internal/store/postgres/...reports no issuesAdminService/SearchOrganizationProjectsandAdminService/ExportOrganizationProjects. An org, four projects and three members were created through the public RPCs, thendeleted_atwas set by SQL. The same scenarios ran againstmainon the same database, with only the binary swapped.member_countdrops the soft-deleted user and the soft-deleted policyuser_idsholds only the live membersname eqthe soft-deleted project returns nothingname eqa live project still returns itSQL Safety
?placeholders,goqu.Ex{}, orgoqu.Record{}— neverfmt.Sprintfor+building a query that gets executed.ToSQL()callers capture and forward params (query, params, err := stmt.ToSQL(); db.…Context(ctx, …, query, params...)). Neverquery, _, err := ….?placeholders inside single-quoted SQL literals ingoqu.L.//nolint:forbidigoor// #nosec G20xannotations.