transactions rework integration#1092
Conversation
Older cmux preview screenshots (latest comment is below)Preview Screenshots⏳ Preview screenshots are being captured... Workspace and dev browser links will appear here once the preview environment is ready. Generated by cmux preview system |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the 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 |
There was a problem hiding this comment.
Greptile Overview
Greptile Summary
This PR integrates the transactions rework by fixing critical pagination bugs and consolidating transaction handling logic.
Key Changes:
- Fixed critical infinite loop bug in
PaginatedList.nextOrPrev()by changing OR to AND in while condition - Fixed off-by-one pagination hack in
listTransactions()by using properisLastflag instead of fetching extra items - Improved merge cursor tracking in
PaginatedList.merge()for correct pagination state - Consolidated transaction builder logic from separate file into
new-transactions.ts - Simplified API route handler to delegate to
listTransactions()helper - Added support for new transaction types in frontend (new-stripe-sub, stripe-resub, stripe-one-time, etc.)
- Added
customerIdfilter parameter to transaction APIs - Comprehensive test coverage for all transaction types and pagination scenarios
Impact:
The pagination bug fixes are critical - the original logic would cause infinite loops in certain edge cases. The refactored code is cleaner, more maintainable, and properly tested.
Confidence Score: 4/5
- This PR is safe to merge with minor risk from pagination logic complexity
- The changes fix critical bugs (infinite loops, off-by-one errors) and are well-tested with comprehensive E2E tests. However, pagination logic is inherently complex and the merge operation involves intricate cursor tracking. The score reflects confidence in the fixes while acknowledging pagination edge cases require careful monitoring in production.
- Pay close attention to
packages/stack-shared/src/utils/paginated-lists.tsx- the pagination logic is complex and any future changes should be carefully reviewed
Important Files Changed
File Analysis
| Filename | Score | Overview |
|---|---|---|
| packages/stack-shared/src/utils/paginated-lists.tsx | 4/5 | Fixed critical pagination loop bug (OR to AND), added progress check, improved merge cursor tracking |
| apps/backend/src/app/api/latest/internal/payments/transactions/route.tsx | 5/5 | Simplified to delegate to listTransactions helper, removed complex cursor logic, cleaner implementation |
| apps/backend/src/lib/new-transactions.ts | 4/5 | Fixed off-by-one pagination bug (removed +1 hack), uses proper PaginatedList API with isLast |
| apps/dashboard/src/components/data-table/transaction-table.tsx | 5/5 | Added support for new transaction types (new-stripe-sub, stripe-resub, etc.), improved type safety |
| apps/e2e/tests/backend/endpoints/api/v1/new-transactions.test.ts | 5/5 | Comprehensive test coverage for all transaction types, pagination, and filters |
Sequence Diagram
sequenceDiagram
participant Client as Dashboard Client
participant API as Transaction API Route
participant Helper as listTransactions()
participant PL as PaginatedList
participant DB as Database
Client->>API: GET /internal/payments/transactions?type=new-stripe-sub&limit=50
API->>Helper: listTransactions(prisma, tenancy, filter, limit)
Helper->>PL: Create individual paginated lists
Note over PL: NewStripeSubPaginatedList<br/>StripeResubPaginatedList<br/>StripeOneTimePaginatedList<br/>etc.
Helper->>PL: PaginatedList.merge(...lists)
Note over PL: Merge all transaction sources
Helper->>PL: mergedList.next(cursor, limit, filter)
loop For each list in parallel
PL->>DB: Fetch subscriptions/invoices/purchases
DB-->>PL: Return rows
PL->>PL: Transform to transactions
end
PL->>PL: Sort and merge results
PL->>PL: Track composite cursor
PL-->>Helper: {items, isLast, cursor}
Helper->>Helper: Extract transactions and nextCursor
Helper-->>API: {transactions, nextCursor, hasMore}
API-->>Client: {transactions, next_cursor, has_more}
Older cmux preview screenshots (latest comment is below)Preview Screenshots⏳ Preview screenshots are being captured... Workspace and dev browser links will appear here once the preview environment is ready. Generated by cmux preview system |
Preview Screenshots⏳ Preview screenshots are being captured... Workspace and dev browser links will appear here once the preview environment is ready. Generated by cmux preview system |
No description provided.