Skip to content

fix(plans): honor Account global filter via plan_accounts join - #715

Merged
cristim merged 1 commit into
feat/multicloud-web-frontendfrom
fix/705-plans-account-filter
May 25, 2026
Merged

cristim merged 1 commit into
feat/multicloud-web-frontendfrom
fix/705-plans-account-filter

Conversation

@cristim

@cristim cristim commented May 25, 2026

Copy link
Copy Markdown
Member

Closes #705. Account chip on Plans page was wired in the UI but the backend list endpoint ignored it; loadPlans skipped account entirely (plans live above accounts and reference them via plan_accounts).

Backend

  • internal/config/types.go — PurchasePlanFilter{AccountIDs []string}.
  • internal/config/interfaces.go — ListPurchasePlans accepts PurchasePlanFilter.
  • internal/config/store_postgres.go — new buildListPlansQuery helper (extracted to stay under gocyclo=10) that conditionally JOINs plan_accounts with parameterized IN placeholders when AccountIDs is non-empty; DISTINCT prevents duplicate rows for plans with multiple matching accounts.
  • internal/api/handler_plans.go — listPlans parses account_ids via the existing parseAccountIDs validator (UUID-checked, capped at 200) and passes PurchasePlanFilter to the store.
  • internal/api/router.go — listPlansHandler passes req.QueryStringParameters through.
  • 11 other mocks/callers updated to pass 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 (mirrors getRecommendations).
  • frontend/src/plans.ts — loadPlans reads state.getCurrentAccountIDs() and passes to getPlans; the existing subscribeAccount subscriber triggers loadPlans on chip changes, completing the end-to-end wiring.

Tests

  • Backend TestHandler_listPlans_AccountIDsFilter — verifies handler passes account IDs to store.
  • Frontend 2 new tests — getPlans called with {account_ids: [...]} when a chip is selected, {} when none.

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
@cristim cristim added triaged Item has been triaged priority/p2 Backlog-worthy severity/low Minor harm urgency/this-quarter Within the quarter impact/few Limited audience effort/s Hours type/bug Defect labels May 25, 2026
@coderabbitai

coderabbitai Bot commented May 25, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@cristim, we couldn't start this review because you've reached your PR review rate limit.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 49df19b2-40b5-4e95-8069-8b42859fd8cb

📥 Commits

Reviewing files that changed from the base of the PR and between f3240f4 and 122c5f1.

📒 Files selected for processing (31)
  • frontend/src/__tests__/plans.test.ts
  • frontend/src/api/plans.ts
  • frontend/src/api/types.ts
  • frontend/src/plans.ts
  • internal/analytics/collector_test.go
  • internal/api/handler_coverage_test.go
  • internal/api/handler_dashboard.go
  • internal/api/handler_dashboard_test.go
  • internal/api/handler_plans.go
  • internal/api/handler_plans_test.go
  • internal/api/handler_purchases.go
  • internal/api/handler_purchases_test.go
  • internal/api/handler_test.go
  • internal/api/mocks_test.go
  • internal/api/router.go
  • internal/config/interfaces.go
  • internal/config/store_postgres.go
  • internal/config/store_postgres_additional_test.go
  • internal/config/store_postgres_comprehensive_test.go
  • internal/config/store_postgres_coverage_test.go
  • internal/config/store_postgres_db_test.go
  • internal/config/store_postgres_pgxmock_test.go
  • internal/config/store_postgres_test.go
  • internal/config/types.go
  • internal/mocks/stores.go
  • internal/purchase/messages_test.go
  • internal/purchase/mocks_test.go
  • internal/purchase/notifications.go
  • internal/purchase/notifications_test.go
  • internal/scheduler/scheduler_test.go
  • internal/server/test_helpers_test.go
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/705-plans-account-filter

Comment @coderabbitai help to get the list of available commands and usage tips.

@cristim

cristim commented May 25, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 25, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@cristim

cristim commented May 25, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 25, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@cristim

cristim commented May 25, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 25, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@cristim

cristim commented May 25, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 25, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@cristim

cristim commented May 25, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 25, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@cristim

cristim commented May 25, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 25, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@cristim
cristim merged commit 5abf40b into feat/multicloud-web-frontend May 25, 2026
5 checks passed
@cristim
cristim deleted the fix/705-plans-account-filter branch May 25, 2026 23:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/s Hours impact/few Limited audience priority/p2 Backlog-worthy severity/low Minor harm triaged Item has been triaged type/bug Defect urgency/this-quarter Within the quarter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant