Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(user): fetch profile_id for sample data #3358

Merged
merged 7 commits into from
Jan 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions crates/router/src/utils/user/sample_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub async fn generate_sample_data(

let business_label_default = merchant_parsed_details.first().map(|x| x.business.clone());

let profile_id = crate::core::utils::get_profile_id_from_business_details(
let profile_id = match crate::core::utils::get_profile_id_from_business_details(
business_country_default,
business_label_default.as_ref(),
&merchant_from_db,
Expand All @@ -61,8 +61,25 @@ pub async fn generate_sample_data(
false,
)
.await
.change_context(SampleDataError::InternalServerError)
.attach_printable("Failed to get business profile")?;
{
Ok(id) => id.clone(),
Err(error) => {
router_env::logger::error!(
"Profile ID not found in business details. Attempting to fetch from the database {error:?}"
);

state
.store
.list_business_profile_by_merchant_id(&merchant_id)
.await
.change_context(SampleDataError::InternalServerError)
.attach_printable("Failed to get business profile")?
.first()
.ok_or(SampleDataError::InternalServerError)?
.profile_id
.clone()
}
};

// 10 percent payments should be failed
#[allow(clippy::as_conversions)]
Expand Down
Loading