refactor(customers): add offset and limit to customers list (#5735)

This commit is contained in:
Narayan Bhat
2024-08-29 12:15:35 +05:30
committed by GitHub
parent 3f17b52a2e
commit be4419865f
10 changed files with 101 additions and 18 deletions

View File

@ -49,6 +49,8 @@ pub async fn rust_locker_migration(
state: SessionState,
merchant_id: &id_type::MerchantId,
) -> CustomResult<services::ApplicationResponse<MigrateCardResponse>, errors::ApiErrorResponse> {
use crate::db::customers::CustomerListConstraints;
let db = state.store.as_ref();
let key_manager_state = &(&state).into();
let key_store = state
@ -67,8 +69,14 @@ pub async fn rust_locker_migration(
.to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)
.change_context(errors::ApiErrorResponse::InternalServerError)?;
// Handle cases where the number of customers is greater than the limit
let constraints = CustomerListConstraints {
limit: u16::MAX,
offset: None,
};
let domain_customers = db
.list_customers_by_merchant_id(key_manager_state, merchant_id, &key_store)
.list_customers_by_merchant_id(key_manager_state, merchant_id, &key_store, constraints)
.await
.change_context(errors::ApiErrorResponse::InternalServerError)?;