fix(plans): honor Account global filter via plan_accounts join - #715
Conversation
Backend: add PurchasePlanFilter{AccountIDs} to config.ListPurchasePlans;
the store JOINs plan_accounts when account IDs are present and returns
DISTINCT plans to handle multi-account memberships. Handler parses
account_ids from query params using the existing parseAccountIDs validator
(UUID-checked, capped at MaxAccountIDsPerRequest=200). Router passes
req.QueryStringParameters to listPlansHandler so the param reaches the
handler.
Frontend: getPlans() now accepts PlanFilters{account_ids} and appends the
param to the URL when non-empty. loadPlans() reads
state.getCurrentAccountIDs() and forwards it to getPlans(), so the
already-wired subscribeAccount subscriber re-fetches with the correct
filter on each chip change.
Closes #705
|
Warning Review limit reached
More reviews will be available in 14 minutes and 11 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (31)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
Closes #705. Account chip on Plans page was wired in the UI but the backend list endpoint ignored it;
loadPlansskipped account entirely (plans live above accounts and reference them viaplan_accounts).Backend
internal/config/types.go—PurchasePlanFilter{AccountIDs []string}.internal/config/interfaces.go—ListPurchasePlansacceptsPurchasePlanFilter.internal/config/store_postgres.go— newbuildListPlansQueryhelper (extracted to stay under gocyclo=10) that conditionally JOINsplan_accountswith parameterized IN placeholders whenAccountIDsis non-empty;DISTINCTprevents duplicate rows for plans with multiple matching accounts.internal/api/handler_plans.go—listPlansparsesaccount_idsvia the existingparseAccountIDsvalidator (UUID-checked, capped at 200) and passesPurchasePlanFilterto the store.internal/api/router.go—listPlansHandlerpassesreq.QueryStringParametersthrough.PurchasePlanFilter{}(preserves existing behavior).Frontend
frontend/src/api/types.ts—PlanFilters{account_ids?}.frontend/src/api/plans.ts—getPlans(filters={})appends?account_ids=...when non-empty (mirrorsgetRecommendations).frontend/src/plans.ts—loadPlansreadsstate.getCurrentAccountIDs()and passes togetPlans; the existingsubscribeAccountsubscriber triggersloadPlanson chip changes, completing the end-to-end wiring.Tests
TestHandler_listPlans_AccountIDsFilter— verifies handler passes account IDs to store.getPlanscalled with{account_ids: [...]}when a chip is selected,{}when none.