Repository navigation
feat(approvals): surface Account/Term/Payment/Monthly + user email in Approval queue - #713
Conversation
|
Warning Review limit reached
More reviews will be available in 10 minutes and 13 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 (7)
✨ 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.
|
… Approval queue Add Account, Term, Payment, Monthly Cost columns to the Approval queue renderer and show the creator's email (resolved from the auth service) instead of the raw UUID. Backend: PurchaseHistoryRecord gains CreatedByUserEmail (non-persisted). executionToHistoryRow accepts the resolved email; fetchExecutionsAsHistory builds a per-request user-ID-to-email cache via resolveUserEmails (one GetUser call per distinct creator, logs+skips on failure). Frontend types: HistoryPurchase extended with account_id, payment, monthly_cost, created_by_user_email (term was already present). recommendations.ts exports getAccountName() so history.ts can resolve account names from the shared cache without duplicating the map. renderApprovalQueue gains Account/Term/Payment/Monthly Cost columns; the Created-by cell falls back UUID -> "-" when email is absent. Effective Savings column: the existing "Monthly Savings" label already matches the actual semantic (estimated_savings is a monthly figure), so no rename or formula change is needed (row 1.3 resolved by option B). Tests: two new Go sub-tests for email resolution and graceful degradation; six new TS tests covering each new column and the email/UUID fallback chain. Closes #704
3532540 to
e3ca433
Compare
|
Rebased onto feat/multicloud-web-frontend@6f6b68b4d to resolve conflicts in
New HEAD: @coderabbitai review |
|
✅ Actions performedReview triggered.
|
…e rows (closes #733) (#734) PR #713 added the Account, Term, Payment, and Monthly Cost columns to the Approval queue card; the columns render but every row showed "-" because the backend never copied those fields onto the synthesised PurchaseHistoryRecord: - Account: executionToHistoryRow read exec.CloudAccountID, but the web-initiated bulk-purchase flow (buildPendingExecution) only populates the per-recommendation CloudAccountID and leaves the execution-level field nil. Fall back to a new collapseRecommendationAccount helper that returns the shared rec CloudAccountID, or "" (rendered as "-") for a basket genuinely spanning accounts. - Payment: projectRecommendationFields populated Service, ResourceType, Region, Term, UpfrontCost, EstimatedSavings, and (single-rec only) MonthlyCost from the rec, but never set row.Payment. Single-rec now copies r.Payment; multi-rec collapses via collapseRecommendationPayment (same pattern as the existing Provider/Service/Term collapsers), returning "" when recs disagree so the dash fallback stays honest. - MonthlyCost (multi-rec): only the single-rec branch mapped it; the multi-rec branch now sums per-rec MonthlyCost via sumRecommendationMonthlyCost (nil contributes 0, matching the single-rec treatment of nil MonthlyCost). Regression tests: - TestHandler_getHistory_ApprovalQueueColumnsPopulated pins all three shapes (single-rec, multi-rec uniform, multi-rec heterogeneous Payment) so a future refactor cannot silently re-empty the cells. - TestHandler_getHistory_InProgressRowMapsRecFields extended with a Payment assertion. - history-approval-queue.test.ts adds a frontend test that mocks the populated API shape and asserts the cells show real values, not "-".
Closes #704.
Approval queue was missing operationally-critical columns (Account, Term, Payment, Monthly Cost) and showing raw user UUIDs instead of emails. Backend already had the data; frontend just didn't expose it.
Changes
internal/config/types.go— addedCreatedByUserEmailtoPurchaseHistoryRecord(excluded from DB persistence).internal/api/handler_history.go—executionToHistoryRowtakes acreatedByEmailparam; newresolveUserEmails(oneGetUserper distinct creator UUID, fails gracefully);fetchExecutionsAsHistorybuilds the cache once and passes the resolved email per row.internal/api/handler_history_test.go—TestHandler_getHistory_CreatedByUserEmailResolved(happy path + graceful lookup-failure).frontend/src/types.ts—HistoryPurchasegainsaccount_id,payment,monthly_cost,created_by_user_email.frontend/src/recommendations.ts— exportsgetAccountNamebacked by the existingaccountNamesCachesohistory.tsreuses it.frontend/src/history.ts—renderApprovalQueueadds Account / Term / Payment / Monthly Cost columns; Created-by renders email with UUID then dash fallback.history-approval-queue.test.ts.Row 1.3 decision (Effective Savings)
Chose Option B (keep label as 'Monthly Savings' — matches the actual semantic of
estimated_savings). No formula change.Tests
go test ./internal/api/...→ 1234 passhistory-approval-queue.test.ts→ 13 pass