Repository: juspay/hyperswitch
File: crates/router/src/core/revenue_recovery_data_backfill.rs (Rust)

Code before:
    };

    logger::info!(
        "Revenue recovery data backfill completed - Processed: {}, Failed: {}",
        processed_records,
        failed_records
    );

    Ok(ApplicationResponse::Json(response))
}

async fn process_payment_method_record(
    state: &SessionState,
    record: &RevenueRecoveryBackfillRequest,
    cutoff_datetime: Option<time::PrimitiveDateTime>,
) -> Result<(), BackfillError> {
    // Build comprehensive card data from CSV record
    let card_data = match build_comprehensive_card_data(record) {
        Ok(data) => data,
        Err(e) => {
            logger::warn!(
                "Failed to build card data for connector customer id: {}, error: {}.",
                record.customer_id_resp,
                e
            );
            ComprehensiveCardData {
                card_type: Some("card".to_string()),
                card_exp_month: None,
                card_exp_year: None,
                card_network: None,
                card_issuer: None,
                card_issuing_country: None,
                daily_retry_history: None,
            }
        }
    };
    logger::info!(
        "Built comprehensive card data - card_type: {:?}, exp_month: {}, exp_year: {}, network: {:?}, issuer: {:?}, country: {:?}, daily_retry_history: {:?}",
        card_data.card_type,
        card_data.card_exp_month.as_ref().map(|_| "**").unwrap_or("None"),
        card_data.card_exp_year.as_ref().map(|_| "**").unwrap_or("None"),
        card_data.card_network,
        card_data.card_issuer,
        card_data.card_issuing_country,
        card_data.daily_retry_history
    );

    // Update Redis if token exists and is valid
    match record.token.as_ref().map(|token| token.clone().expose()) {
        Some(token) if !token.is_empty() => {
            logger::info!("Updating Redis for customer: {}", record.customer_id_resp,);

Review comment (suggestion):
```suggestion
        .change_context(errors::ApiErrorResponse::InternalServerError)
        .attach_printable("Some error message")?;
```

Code after:
    };

    logger::info!(
        "Revenue recovery data backfill completed - Processed: {}, Failed: {}",
        processed_records,
        failed_records
    );

    Ok(ApplicationResponse::Json(response))
}

pub async fn unlock_connector_customer_status(
    state: SessionState,
    connector_customer_id: String,
) -> RouterResult<ApplicationResponse<UnlockStatusResponse>> {
    let unlocked = storage::revenue_recovery_redis_operation::
        RedisTokenManager::unlock_connector_customer_status(&state, &connector_customer_id)
        .await
        .map_err(|e| {
            logger::error!(
                "Failed to unlock connector customer status for {}: {}",
                connector_customer_id,
                e
            );
            errors::ApiErrorResponse::InternalServerError
        })?;

    let response = UnlockStatusResponse { unlocked };

    logger::info!(
        "Unlock operation completed for connector customer {}: {}",
        connector_customer_id,
        unlocked
    );

    Ok(ApplicationResponse::Json(response))
}

async fn process_payment_method_record(
    state: &SessionState,
    record: &RevenueRecoveryBackfillRequest,
    cutoff_datetime: Option<time::PrimitiveDateTime>,
) -> Result<(), BackfillError> {
    // Build comprehensive card data from CSV record
    let card_data = match build_comprehensive_card_data(record) {
        Ok(data) => data,
        Err(e) => {
            logger::warn!(
                "Failed to build card data for connector customer id: {}, error: {}.",
                record.customer_id_resp,
                e