mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-05 17:58:55 +00:00
fix four more errors
This commit is contained in:
1 parent
3022193ff7
commit
e8dc191d8e
2 files changed
+34
-59
No files matched your search
@@ -7,36 +7,34 @@ use sqlx::MySqlPool;
|
||||
#[derive(Serialize)]
|
||||
pub struct TtsModelRecordForList {
|
||||
pub model_token: String,
|
||||
pub model_type: String,
|
||||
pub tts_model_type: String,
|
||||
|
||||
pub title: String,
|
||||
pub updatable_slug: String,
|
||||
|
||||
pub creator_user_token: String,
|
||||
pub creator_username: String,
|
||||
pub creator_display_name: String,
|
||||
pub updatable_slug: String,
|
||||
pub title: String,
|
||||
pub frame_width: u32,
|
||||
pub frame_height: u32,
|
||||
pub duration_millis: u32,
|
||||
pub maybe_image_object_name: Option<String>,
|
||||
pub maybe_video_object_name: Option<String>,
|
||||
pub is_mod_approved: bool, // converted
|
||||
|
||||
pub is_mod_disabled: bool, // converted
|
||||
|
||||
pub created_at: DateTime<Utc>,
|
||||
pub updated_at: DateTime<Utc>,
|
||||
}
|
||||
|
||||
struct RawTtsModelRecordForList {
|
||||
pub model_token: String,
|
||||
pub model_type: String,
|
||||
pub tts_model_type: String,
|
||||
|
||||
pub title: String,
|
||||
pub updatable_slug: String,
|
||||
|
||||
pub creator_user_token: String,
|
||||
pub creator_username: String,
|
||||
pub creator_display_name: String,
|
||||
pub updatable_slug: String,
|
||||
pub title: String,
|
||||
pub frame_width: i32,
|
||||
pub frame_height: i32,
|
||||
pub duration_millis: i32,
|
||||
pub maybe_public_bucket_preview_image_object_name: Option<String>,
|
||||
pub maybe_public_bucket_preview_video_object_name: Option<String>,
|
||||
pub is_mod_approved: i8, // NB: needs conversion
|
||||
|
||||
pub is_mod_disabled: i8, // NB: needs conversion
|
||||
|
||||
pub created_at: DateTime<Utc>,
|
||||
pub updated_at: DateTime<Utc>,
|
||||
}
|
||||
@@ -82,18 +80,13 @@ pub async fn list_tts_models(
|
||||
.map(|model| {
|
||||
TtsModelRecordForList {
|
||||
model_token: model.model_token.clone(),
|
||||
model_type: model.model_type.clone(),
|
||||
tts_model_type: model.tts_model_type.clone(),
|
||||
creator_user_token: model.creator_user_token.clone(),
|
||||
creator_username: model.creator_username.clone(),
|
||||
creator_display_name: model.creator_display_name.clone(),
|
||||
updatable_slug: model.updatable_slug.clone(),
|
||||
title: model.title.clone(),
|
||||
frame_width: if model.frame_width > 0 { model.frame_width as u32 } else { 0 },
|
||||
frame_height: if model.frame_height > 0 { model.frame_height as u32 } else { 0 },
|
||||
duration_millis: if model.duration_millis > 0 { model.duration_millis as u32 } else { 0 },
|
||||
maybe_image_object_name: model.maybe_public_bucket_preview_image_object_name.clone(),
|
||||
maybe_video_object_name: model.maybe_public_bucket_preview_video_object_name.clone(),
|
||||
is_mod_approved: if model.is_mod_approved == 0 { false } else { true },
|
||||
is_mod_disabled: if model.is_mod_disabled == 0 { false } else { true },
|
||||
created_at: model.created_at.clone(),
|
||||
updated_at: model.updated_at.clone(),
|
||||
}
|
||||
@@ -103,29 +96,24 @@ pub async fn list_tts_models(
|
||||
|
||||
async fn list_tts_models_for_all_creators(
|
||||
mysql_pool: &MySqlPool,
|
||||
require_mod_approved: bool
|
||||
allow_mod_disabled: bool
|
||||
) -> AnyhowResult<Vec<RawTtsModelRecordForList>> {
|
||||
// TODO: There has to be a better way.
|
||||
// Sqlx doesn't like anything except string literals.
|
||||
let maybe_models = if require_mod_approved {
|
||||
let maybe_models = if !allow_mod_disabled {
|
||||
info!("listing tts models for everyone; mod-approved only");
|
||||
sqlx::query_as!(
|
||||
RawTtsModelRecordForList,
|
||||
r#"
|
||||
SELECT
|
||||
tts.token as model_token,
|
||||
tts.model_type,
|
||||
tts.tts_model_type,
|
||||
tts.creator_user_token,
|
||||
users.username as creator_username,
|
||||
users.display_name as creator_display_name,
|
||||
tts.updatable_slug,
|
||||
tts.title,
|
||||
tts.frame_width,
|
||||
tts.frame_height,
|
||||
tts.duration_millis,
|
||||
tts.maybe_public_bucket_preview_image_object_name,
|
||||
tts.maybe_public_bucket_preview_video_object_name,
|
||||
tts.is_mod_approved,
|
||||
tts.is_mod_disabled,
|
||||
tts.created_at,
|
||||
tts.updated_at
|
||||
FROM tts_models as tts
|
||||
@@ -133,7 +121,7 @@ JOIN users
|
||||
ON users.token = tts.creator_user_token
|
||||
WHERE
|
||||
tts.deleted_at IS NULL
|
||||
AND tts.is_mod_approved IS TRUE
|
||||
AND tts.is_mod_disabled IS FALSE
|
||||
"#)
|
||||
.fetch_all(mysql_pool)
|
||||
.await?
|
||||
@@ -144,18 +132,13 @@ WHERE
|
||||
r#"
|
||||
SELECT
|
||||
tts.token as model_token,
|
||||
tts.model_type,
|
||||
tts.tts_model_type,
|
||||
tts.creator_user_token,
|
||||
users.username as creator_username,
|
||||
users.display_name as creator_display_name,
|
||||
tts.updatable_slug,
|
||||
tts.title,
|
||||
tts.frame_width,
|
||||
tts.frame_height,
|
||||
tts.duration_millis,
|
||||
tts.maybe_public_bucket_preview_image_object_name,
|
||||
tts.maybe_public_bucket_preview_video_object_name,
|
||||
tts.is_mod_approved,
|
||||
tts.is_mod_disabled,
|
||||
tts.created_at,
|
||||
tts.updated_at
|
||||
FROM tts_models as tts
|
||||
@@ -174,29 +157,24 @@ WHERE
|
||||
async fn list_tts_models_creator_scoped(
|
||||
mysql_pool: &MySqlPool,
|
||||
scope_creator_username: &str,
|
||||
require_mod_approved: bool
|
||||
allow_mod_disabled: bool
|
||||
) -> AnyhowResult<Vec<RawTtsModelRecordForList>> {
|
||||
// TODO: There has to be a better way.
|
||||
// Sqlx doesn't like anything except string literals.
|
||||
let maybe_models = if require_mod_approved {
|
||||
let maybe_models = if !allow_mod_disabled {
|
||||
info!("listing tts models for user; mod-approved only");
|
||||
sqlx::query_as!(
|
||||
RawTtsModelRecordForList,
|
||||
r#"
|
||||
SELECT
|
||||
tts.token as model_token,
|
||||
tts.model_type,
|
||||
tts.tts_model_type,
|
||||
tts.creator_user_token,
|
||||
users.username as creator_username,
|
||||
users.display_name as creator_display_name,
|
||||
tts.updatable_slug,
|
||||
tts.title,
|
||||
tts.frame_width,
|
||||
tts.frame_height,
|
||||
tts.duration_millis,
|
||||
tts.maybe_public_bucket_preview_image_object_name,
|
||||
tts.maybe_public_bucket_preview_video_object_name,
|
||||
tts.is_mod_approved,
|
||||
tts.is_mod_disabled,
|
||||
tts.created_at,
|
||||
tts.updated_at
|
||||
FROM tts_models as tts
|
||||
@@ -205,7 +183,7 @@ ON
|
||||
users.token = tts.creator_user_token
|
||||
WHERE
|
||||
tts.deleted_at IS NULL
|
||||
AND tts.is_mod_approved IS TRUE
|
||||
AND tts.is_mod_disabled IS FALSE
|
||||
AND users.username = ?
|
||||
"#,
|
||||
scope_creator_username)
|
||||
@@ -218,18 +196,13 @@ WHERE
|
||||
r#"
|
||||
SELECT
|
||||
tts.token as model_token,
|
||||
tts.model_type,
|
||||
tts.tts_model_type,
|
||||
tts.creator_user_token,
|
||||
users.username as creator_username,
|
||||
users.display_name as creator_display_name,
|
||||
tts.updatable_slug,
|
||||
tts.title,
|
||||
tts.frame_width,
|
||||
tts.frame_height,
|
||||
tts.duration_millis,
|
||||
tts.maybe_public_bucket_preview_image_object_name,
|
||||
tts.maybe_public_bucket_preview_video_object_name,
|
||||
tts.is_mod_approved,
|
||||
tts.is_mod_disabled,
|
||||
tts.created_at,
|
||||
tts.updated_at
|
||||
FROM tts_models as tts
|
||||
|
||||
@@ -70,6 +70,8 @@ use crate::http_server::endpoints::tts::get_tts_model::get_tts_model_handler;
|
||||
// TODO TODO TODO TODO
|
||||
// TODO TODO TODO TODO
|
||||
|
||||
// TODO TODO TODO -- ON signup, add an "early adopter" badge. And a tool for making it easy to add badges.
|
||||
// TODO - badge for uploading template, badge for uploading model, etc.
|
||||
|
||||
|
||||
const DEFAULT_BIND_ADDRESS : &'static str = "0.0.0.0:12345";
|
||||
|
||||
Reference in new issue
Block a user