feat: batch payout txs, background analytics, submissions pagination - #2134
Merged
RUKAYAT-CODER merged 2 commits intoJul 29, 2026
Merged
Conversation
Implements three performance improvement issues: EarnQuestOne#1981 - Batch payout transactions - Add sendBatchPayments() to StellarService for multi-op transactions - Add processBatchPayouts() cron job in PayoutsService (every 30s) - Groups eligible payouts by asset, up to 100 ops per tx - Partial failure handling with per-op result tracking - Metrics: batch_payout_total, batch_payout_operations, batch_payout_size EarnQuestOne#2004 - Move analytics to background jobs - PlatformAnalyticsService now serves from AnalyticsSnapshot first - computeAndStorePlatformStats() persists results to DB snapshots - Background cron (every 5 min) pre-computes platform stats - Falls back to live computation when no fresh snapshot exists - Metrics: analytics_computation_total, analytics_computation_duration_seconds EarnQuestOne#1973 - Pagination limit clamp for submissions - Wire QuerySubmissionsDto to GET /quests/:questId/submissions - Cursor-based pagination with limit clamp (max 100 via @max(100)) - Supports status, userId filters and sortBy/order options - Returns PaginatedResponseDto with nextCursor/hasMore
|
@k-deejah Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Contributor
|
kindly resolve conflict |
Contributor
|
Thank you for contributing to the project. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR implements three performance improvement issues targeting batch payouts, background analytics computation, and submissions pagination.
Linked Issues
Changes Made
#1981 — Batch payout transactions
Problem: Individual payouts are submitted as separate transactions, incurring per-transaction fees and RPC round-trips.
Solution: Group eligible payouts into multi-operation Stellar transactions (up to 100 ops/tx).
StellarService.sendBatchPayments()(src/modules/stellar/stellar.service.ts): Builds a singleTransactionBuilderwith multipleOperation.payment()calls, signs once, submits once. Splits into multiple transactions when input exceeds 100 operations.PayoutsService.processBatchPayouts()(src/modules/payouts/payouts.service.ts): Cron job (every 30s) that queries pending/retry payouts, groups by asset, delegates tosendBatchPayments(). Handles partial failures per-payout.claimPayoutto set status toPENDINGso batch cron picks it up.batch_payout_total,batch_payout_operations,batch_payout_size.#2004 — Move analytics to background jobs
Problem: Synchronous analytics computation blocks request threads and risks timeouts.
Solution: Compute in background jobs, persist results, serve precomputed data.
PlatformAnalyticsService.getPlatformStats()(src/modules/analytics/services/platform-analytics.service.ts): First attempts to serve from the most recentAnalyticsSnapshot(within 5 min). Falls back to live computation when no fresh snapshot exists.computeAndStorePlatformStats(): Computes full platform stats and persists toanalytics_snapshotstable via upsert.@Cron(EVERY_5_MINUTES) computePlatformAnalytics(): Scheduled background job that pre-computes stats for the last 30 days.analytics_computation_total(source: snapshot|live),analytics_computation_duration_seconds.#1973 — Pagination limit clamp for submissions
Problem:
GET /quests/:questId/submissionsaccepted unbounded limits, returning all submissions.Solution: Wired existing
QuerySubmissionsDtoto controller; cursor-based pagination with@Max(100)limit clamp.src/modules/submissions/submissions.controller.ts): Accepts@Query() query: QuerySubmissionsDto.findByQuest()(src/modules/submissions/submissions.service.ts): Cursor-based pagination with filters (status,userId), sort (sortBy,order), limit (default 10, max 100).PaginatedResponseDto<Submission>withdata,nextCursor,hasMore.Type of Change
Test Evidence
Unit Tests
sendBatchPayments(multi-op tx, >100 splits)npm run test)Test output:
TypeScript Compilation
Performance Impact