Repository navigation
feat(backend): implement user search autocomplete, Redis batch lock, chunked disbursement worker, and session refresh middleware - #1079
Merged
ONEONUORA merged 1 commit intoSep 25, 2026
Conversation
…chunked disbursement worker, and session refresh middleware - Fracverse#953: User Search Autocomplete with Trigram Index Support - Query Postgres using ILIKE 'query%' prefix pattern matching accelerated by pg_trgm GIN index (idx_users_username_trgm) and similarity scoring - Re-export api::user as api::users in api/mod.rs - Add unit tests for prefix matching and pattern escaping in user.rs - Fracverse#952: Redis Distributed Lock for Payout Batch Processing - Expose BatchLock::lock_key helper and acquire lock key lock:batch:{id} with TTL before executing batch disbursement in services/redis_cache.rs - Connect BatchLock in disbursement_worker.rs and main.rs to prevent duplicate batch execution across multiple worker replicas - Release lock upon cycle completion; add unit tests for key formatting and connection validation - Fracverse#951: Batch Disbursement Chunked Executor Worker - Slice batch recipient items into sub-chunks of 50 operations (.div_ceil(CHUNK_SIZE)) to prevent gas limit issues on-chain - Submit transactions sequentially within each chunk and update database status/progress (payout_batches updated_at and dispatch_logs) per chunk - Add unit tests verifying chunking of 50 operations - Fracverse#943: Session Refresh & Authorization Middleware with Privy Credentials - Add POST /api/auth/refresh endpoint in api/auth.rs and api/mod.rs to refresh authenticated sessions - Extract token parameters from Authorization Bearer header or request payload - Authorize requests matching validated user entities (via cache hit or Privy JWKS/local validation + DB resolution) - Cache token validation states in AuthTokenCache with TTL to avoid repeated remote checks - Wire auth_cache into AuthState in main.rs and fix mock token handling in auth_middleware.rs - Add comprehensive test coverage in privy_auth_mock.rs and privy_auth_tests.rs Closes Fracverse#953 Closes Fracverse#952 Closes Fracverse#951 Closes Fracverse#943
|
@ayomideadeniran 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! 🚀 |
ONEONUORA
approved these changes
Sep 25, 2026
ONEONUORA
left a comment
Contributor
There was a problem hiding this comment.
Great job @ayomideadeniran
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.
Summary
This pull request addresses and resolves issues #953, #952, #951, and #943 across the backend services and API layers:
backend: IMPLEMENT USER SEARCH AUTOCOMPLETE API WITH TRIGRAM INDEX SUPPORT #953: User Search Autocomplete API with Trigram Index Support
GET /api/users/autocomplete?q=&limit=accelerated by Postgrespg_trgmGIN index (idx_users_username_trgm) and btree pattern ops.LOWER(username) ILIKE $2 ESCAPE '\'with escaped prefix matching patterns (query%) and pg_trgmsimilarity()ranking.api::userasapi::usersinbackend/src/api/mod.rsfor unified module accessibility.backend/src/api/user.rs.backend: CREATE REDIS DISTRIBUTED LOCK FOR PAYOUT BATCH PROCESSING #952: Redis Distributed Lock for Payout Batch Processing
BatchLockinbackend/src/services/redis_cache.rswithlock_key(batch_id)(lock:batch:{id}), acquiring distributed locks via atomic RedisSET key value NX PX ttl(5-minute default TTL).BatchLockintoDisbursementWorkerConfigandprocess_cycleinbackend/src/services/disbursement_worker.rs, acquiring the batch lock before execution to prevent concurrent duplicate processing across worker replicas.backend: IMPLEMENT BATCH DISBURSEMENT CHUNKED EXECUTOR WORKER #951: Batch Disbursement Chunked Executor Worker
CHUNK_SIZE = 50inbackend/src/services/disbursement_worker.rsto process large batches in sub-chunks of 50 operations (.div_ceil(CHUNK_SIZE)), preventing on-chain gas limit contention.record_chunk_progressto update database status (payout_batches.updated_at) and log dispatch progress (dispatch_logs) per chunk.backend: Implement session refresh and authorization middleware with Privy credentials #943: Session Refresh & Authorization Middleware with Privy Credentials
POST /api/auth/refreshendpoint inbackend/src/api/auth.rsand wired it intoauth_routes_with_limiterinbackend/src/api/mod.rs.Authorization: Bearer <token>header or JSON payload.AuthTokenCachewith TTL to avoid repeated remote checks.auth_cacheintoAuthStateinbackend/src/main.rs.validate_jwt_localmock token handling inauth_middleware.rs.tests/privy_auth_mock.rsandtests/privy_auth_tests.rs.Changes by File
backend/src/api/user.rs:autocompleteendpoint usingILIKE 'query%'with trigram index.backend/src/services/redis_cache.rs:lock_keyhelper toBatchLockgeneratinglock:batch:{batch_id}.backend/src/services/disbursement_worker.rs:batch_lock: Option<BatchLock>toDisbursementWorkerConfiginitialized fromREDIS_URL.lock:batch:{id}inprocess_cycleprior to batch execution and released upon completion.backend/src/api/auth.rs:cache: Option<AuthTokenCache>toAuthStatewith constructorsnew()andwith_cache().RefreshSessionRequestandRefreshSessionResponse.refresh_sessionhandler that extracts token parameters, validates user entities, issues a renewed JWT token, and caches token states to avoid repeated remote checks.stellar_address()method onPrivyTokenPayload.backend/src/api/auth_middleware.rs:CachedSession::new()constructor."mock-jwt-token-string"handling tovalidate_jwt_localto matchvalidate_jwt_async.backend/src/api/mod.rs:pub use user as users;./refreshroute toauth_routes_with_limiter.backend/src/main.rs:BatchLockfromREDIS_URLand passed it todisbursement_config.auth_cachetoAuthStateinsensitive_routes.backend/tests/privy_auth_mock.rs&backend/tests/privy_auth_tests.rs:/api/auth/refreshwith cached sessions, missing tokens, and invalid tokens.AuthStateandprotected_routes.Verification
cargo check --manifest-path backend/Cargo.toml: Passedcargo clippy --manifest-path backend/Cargo.toml --all-targets -- -D warnings: Passed (0 warnings)cargo test --manifest-path backend/Cargo.toml --lib: Passed (133 tests passed, 0 failed)cargo test --manifest-path backend/Cargo.toml --test privy_auth_mock: Passed (12 tests passed, 0 failed)cargo test --manifest-path backend/Cargo.toml --test privy_auth_tests: Passed (16 tests passed, 0 failed)Closes #953
Closes #952
Closes #951
Closes #943