From 41b07049ffb32e46217cd4c145865d36366436cb Mon Sep 17 00:00:00 2001 From: Michael Chung Date: Mon, 23 Oct 2023 21:29:41 -0400 Subject: [PATCH] Remove comments --- .../voice_designer/voices/create_voice.rs | 104 +++++++++--------- 1 file changed, 49 insertions(+), 55 deletions(-) diff --git a/crates/lib/mysql_queries/src/queries/voice_designer/voices/create_voice.rs b/crates/lib/mysql_queries/src/queries/voice_designer/voices/create_voice.rs index 1f569dff31..674f58bb3b 100644 --- a/crates/lib/mysql_queries/src/queries/voice_designer/voices/create_voice.rs +++ b/crates/lib/mysql_queries/src/queries/voice_designer/voices/create_voice.rs @@ -10,54 +10,47 @@ use tokens::tokens::users::UserToken; use crate::queries::generic_synthetic_ids::transactional_increment_generic_synthetic_id::transactional_increment_generic_synthetic_id; - - -// Model category? Zero shot? -// Model type? end to end TTS / VC vs cascading TTS / VC -// Model version? 1? -// Encoding Type? npz ? -// - pub struct CreateVoiceArgs<'a> { - pub dataset_token: &'a ZsVoiceDatasetToken, + pub dataset_token: &'a ZsVoiceDatasetToken, - // TODO(bt,2023-10-06): These should be *Rust Enums* to limit their possible range of values. - pub model_category: &'a str, - pub model_type: &'a str, - pub model_version: u64, - pub model_encoding_type: &'a str, + // TODO(bt,2023-10-06): These should be *Rust Enums* to limit their possible range of values. + pub model_category: &'a str, + pub model_type: &'a str, + pub model_version: u64, + pub model_encoding_type: &'a str, - pub voice_title: &'a str, - // TODO(Kasisnu): Is this a create/update field? - // should it be nullable - pub bucket_hash: &'a str, - pub maybe_creator_user_token: Option<&'a UserToken>, + pub voice_title: &'a str, + // TODO(Kasisnu): Is this a create/update field? + // should it be nullable + pub bucket_hash: &'a str, + pub maybe_creator_user_token: Option<&'a UserToken>, - pub creator_ip_address: &'a str, - pub creator_set_visibility: Visibility, - pub mysql_pool: &'a MySqlPool + pub creator_ip_address: &'a str, + pub creator_set_visibility: Visibility, + pub mysql_pool: &'a MySqlPool, } -pub async fn create_voice(args: CreateVoiceArgs<'_>) -> AnyhowResult{ - let voice_token = ZsVoiceToken::generate(); +pub async fn create_voice(args: CreateVoiceArgs<'_>) -> AnyhowResult { + let voice_token = ZsVoiceToken::generate(); - // TODO: enforce checks for idempotency token - let mut maybe_creator_synthetic_id : Option = None; + // TODO: enforce checks for idempotency token + let mut maybe_creator_synthetic_id: Option = None; - let mut transaction = args.mysql_pool.begin().await?; + let mut transaction = args.mysql_pool.begin().await?; - if let Some(creator_user_token) = args.maybe_creator_user_token.as_deref() { - let next_zs_dataset_synthetic_id = transactional_increment_generic_synthetic_id( - creator_user_token, - IdCategory::ZsDataset, - &mut transaction - ).await?; + if let Some(creator_user_token) = args.maybe_creator_user_token.as_deref() { + let next_zs_dataset_synthetic_id = transactional_increment_generic_synthetic_id( + creator_user_token, + IdCategory::ZsDataset, + &mut transaction + ).await?; - maybe_creator_synthetic_id = Some(next_zs_dataset_synthetic_id); - } + maybe_creator_synthetic_id = Some(next_zs_dataset_synthetic_id); + } - let query_result = sqlx::query!( - r#" + let query_result = sqlx + ::query( + r#" INSERT INTO zs_voices SET token = ?, @@ -72,24 +65,25 @@ pub async fn create_voice(args: CreateVoiceArgs<'_>) -> AnyhowResult Ok(voice_token), - Err(err) => Err(anyhow!("zs voice creation error: {:?}", err)), - } + match query_result { + Ok(_) => Ok(voice_token), + Err(err) => Err(anyhow!("zs voice creation error: {:?}", err)), + } }