edit tts model m-factor (mods only)

This commit is contained in:
Brandon Thomas committed 2023-03-11 03:41:59 -05:00
1 parent f978f1b055
commit e372a4b5ec
4 files changed
+38

No files matched your search

@@ -18,6 +18,8 @@ pub async fn edit_tts_model_moderator_details(
is_twitch_featured: bool,
moderator_user_token: &str,
maybe_mod_comments: Option<&str>,
use_default_mel_multiply_factor: bool,
maybe_custom_mel_multiply_factor: Option<f64>,
) -> Result<MySqlQueryResult, sqlx::Error> {
sqlx::query!(
r#"
@@ -31,6 +33,8 @@ SET
is_front_page_featured = ?,
is_twitch_featured = ?,
maybe_suggested_unique_bot_command = ?,
use_default_mel_multiply_factor = ?,
maybe_custom_mel_multiply_factor = ?,
version = version + 1
WHERE token = ?
LIMIT 1
@@ -43,6 +47,8 @@ LIMIT 1
is_front_page_featured,
is_twitch_featured,
maybe_suggested_unique_bot_command,
use_default_mel_multiply_factor,
maybe_custom_mel_multiply_factor,
tts_model_token
)
.execute(mysql_pool)
@@ -71,6 +71,10 @@ pub struct CustomVocoderFields {
/// "Moderator-only fields" that we wouldn't want to expose to ordinary users.
/// It's the web endpoint controller's responsibility to clear these for non-mods.
pub struct TtsModelModeratorFields {
// Moderator-set mel multiply factors
pub use_default_mel_multiply_factor: bool,
pub maybe_custom_mel_multiply_factor: Option<f64>,
pub creator_is_banned: bool,
pub creator_ip_address_creation: String,
pub creator_ip_address_last_update: String,
@@ -166,6 +170,8 @@ pub async fn get_tts_model_by_token_using_connection(
created_at: model.created_at,
updated_at: model.updated_at,
maybe_moderator_fields: Some(TtsModelModeratorFields {
use_default_mel_multiply_factor: i8_to_bool(model.use_default_mel_multiply_factor),
maybe_custom_mel_multiply_factor: model.maybe_custom_mel_multiply_factor,
creator_is_banned: i8_to_bool(model.creator_is_banned),
creator_ip_address_creation: model.creator_ip_address_creation,
creator_ip_address_last_update: model.creator_ip_address_last_update,
@@ -191,6 +197,9 @@ SELECT
tts.text_preprocessing_algorithm,
tts.maybe_default_pretrained_vocoder,
tts.use_default_mel_multiply_factor,
tts.maybe_custom_mel_multiply_factor,
tts.creator_user_token,
users.username as creator_username,
users.display_name as creator_display_name,
@@ -264,6 +273,9 @@ SELECT
tts.text_preprocessing_algorithm,
tts.maybe_default_pretrained_vocoder,
tts.use_default_mel_multiply_factor,
tts.maybe_custom_mel_multiply_factor,
tts.creator_user_token,
users.username as creator_username,
users.display_name as creator_display_name,
@@ -334,6 +346,9 @@ struct InternalTtsModelRecordRaw {
pub maybe_default_pretrained_vocoder: Option<String>,
pub text_preprocessing_algorithm: String,
pub use_default_mel_multiply_factor: i8,
pub maybe_custom_mel_multiply_factor: Option<f64>,
pub creator_user_token: String,
pub creator_username: String,
pub creator_display_name: String,
@@ -81,6 +81,11 @@ pub struct EditTtsModelRequest {
// NB: We take "empty string" to mean removal.
pub maybe_suggested_unique_bot_command: Option<String>,
// Moderator-set mel multiply factors
// These fields are misleadingly named just in case a competitor is snooping the javascript.
pub use_default_m_factor: Option<bool>,
pub maybe_custom_m_factor: Option<f64>,
}
#[derive(Debug)]
@@ -351,6 +356,9 @@ async fn update_mod_details(
}
}
let use_default_mel_multiply_factor = request.use_default_m_factor.unwrap_or(false);
let maybe_custom_mel_multiply_factor = request.maybe_custom_m_factor;
let query_result = edit_tts_model_moderator_details(
&mysql_pool,
tts_model_token,
@@ -362,6 +370,8 @@ async fn update_mod_details(
is_twitch_featured,
moderator_user_token,
request.maybe_mod_comments.as_deref(),
use_default_mel_multiply_factor,
maybe_custom_mel_multiply_factor,
).await;
match query_result {
@@ -117,6 +117,11 @@ pub struct UserRatingsStats {
/// It's the web endpoint controller's responsibility to clear these for non-mods.
#[derive(Serialize)]
pub struct TtsModelModeratorFieldInfo {
// Moderator-set mel multiply factors
// These fields are misleadingly named just in case a competitor is snooping the javascript.
pub use_default_m_factor: bool,
pub maybe_custom_m_factor: Option<f64>,
pub creator_is_banned: bool,
pub creator_ip_address_creation: String,
pub creator_ip_address_last_update: String,
@@ -286,6 +291,8 @@ pub async fn get_tts_model_handler(
updated_at: model.updated_at,
maybe_moderator_fields: model.maybe_moderator_fields.map(|mod_fields| {
TtsModelModeratorFieldInfo {
use_default_m_factor: mod_fields.use_default_mel_multiply_factor,
maybe_custom_m_factor: mod_fields.maybe_custom_mel_multiply_factor,
creator_is_banned: mod_fields.creator_is_banned,
creator_ip_address_creation: mod_fields.creator_ip_address_creation,
creator_ip_address_last_update: mod_fields.creator_ip_address_last_update,