mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-03 00:47:53 +00:00
update code references (avatar -> cover_image)
This commit is contained in:
1 parent
fae36d485b
commit
2c7400bf76
21 files changed
+117
-287
No files matched your search
+1
-3
@@ -63,9 +63,7 @@ SET
|
||||
weights_category = ?,
|
||||
title = ?,
|
||||
|
||||
maybe_thumbnail_token = NULL,
|
||||
maybe_avatar_media_file_token = NULL,
|
||||
maybe_cover_media_file_token = NULL,
|
||||
maybe_cover_image_media_file_token = NULL,
|
||||
description_markdown = NULL,
|
||||
description_rendered_html = NULL,
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@ pub struct CreateModelWeightsArgs<'a> {
|
||||
pub weights_type: WeightsType,
|
||||
pub weights_category: WeightsCategory,
|
||||
pub title: String,
|
||||
pub maybe_thumbnail_token: Option<String>,
|
||||
pub description_markdown: String,
|
||||
pub description_rendered_html: String,
|
||||
pub creator_user_token: Option<&'a UserToken>,
|
||||
@@ -47,7 +46,6 @@ pub async fn create_weight(args: CreateModelWeightsArgs<'_>) -> AnyhowResult<Mod
|
||||
weights_type = ?,
|
||||
weights_category = ?,
|
||||
title = ?,
|
||||
maybe_thumbnail_token = ?,
|
||||
description_markdown = ?,
|
||||
description_rendered_html = ?,
|
||||
creator_user_token = ?,
|
||||
@@ -71,7 +69,6 @@ pub async fn create_weight(args: CreateModelWeightsArgs<'_>) -> AnyhowResult<Mod
|
||||
args.weights_type.to_str(),
|
||||
args.weights_category.to_str(),
|
||||
args.title,
|
||||
args.maybe_thumbnail_token,
|
||||
args.description_markdown,
|
||||
args.description_rendered_html,
|
||||
args.creator_user_token.as_deref(),
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
pub mod set_model_weight_avatar;
|
||||
pub mod set_model_weight_cover_image;
|
||||
pub mod update_weight;
|
||||
+4
-4
@@ -6,23 +6,23 @@ use tokens::tokens::model_weights::ModelWeightToken;
|
||||
|
||||
pub struct UpdateArgs<'a> {
|
||||
pub model_weight_token: &'a ModelWeightToken,
|
||||
pub maybe_avatar_media_file_token: Option<&'a MediaFileToken>,
|
||||
pub maybe_cover_image_media_file_token: Option<&'a MediaFileToken>,
|
||||
//pub update_ip_address: &'a str,
|
||||
pub mysql_pool: &'a MySqlPool
|
||||
}
|
||||
|
||||
pub async fn set_model_weight_avatar(args: UpdateArgs<'_>) -> AnyhowResult<()>{
|
||||
pub async fn set_model_weight_cover_image(args: UpdateArgs<'_>) -> AnyhowResult<()>{
|
||||
let transaction = args.mysql_pool.begin().await?;
|
||||
|
||||
let query_result = sqlx::query!(
|
||||
r#"
|
||||
UPDATE model_weights
|
||||
SET
|
||||
maybe_avatar_media_file_token = ?
|
||||
maybe_cover_image_media_file_token = ?
|
||||
WHERE token = ?
|
||||
LIMIT 1
|
||||
"#,
|
||||
args.maybe_avatar_media_file_token,
|
||||
args.maybe_cover_image_media_file_token,
|
||||
args.model_weight_token,
|
||||
).execute(args.mysql_pool).await;
|
||||
|
||||
@@ -8,7 +8,6 @@ use tokens::tokens::model_weights::ModelWeightToken;
|
||||
pub struct UpdateWeightArgs<'a> {
|
||||
pub weight_token: &'a ModelWeightToken,
|
||||
pub title: Option<&'a str>,
|
||||
pub maybe_thumbnail_token: Option<&'a str>,
|
||||
pub description_markdown: Option<&'a str>,
|
||||
pub description_rendered_html: Option<&'a str>,
|
||||
pub creator_set_visibility: Option<&'a Visibility>,
|
||||
@@ -27,7 +26,6 @@ pub async fn update_weights(args: UpdateWeightArgs<'_>) -> AnyhowResult<()> {
|
||||
SET
|
||||
title = COALESCE(?, title),
|
||||
description_markdown = COALESCE(?, description_markdown),
|
||||
maybe_thumbnail_token = COALESCE(?, maybe_thumbnail_token),
|
||||
description_rendered_html = COALESCE(?, description_rendered_html),
|
||||
creator_set_visibility = COALESCE(?, creator_set_visibility),
|
||||
version = version + 1
|
||||
@@ -35,7 +33,6 @@ pub async fn update_weights(args: UpdateWeightArgs<'_>) -> AnyhowResult<()> {
|
||||
"#,
|
||||
args.title.as_deref(),
|
||||
args.description_markdown.as_deref(),
|
||||
args.maybe_thumbnail_token.as_deref(),
|
||||
args.description_rendered_html.as_deref(),
|
||||
args.creator_set_visibility.as_deref(),
|
||||
args.weight_token.as_str()
|
||||
|
||||
@@ -19,7 +19,6 @@ pub struct RetrivedModelWeight {
|
||||
pub title: String,
|
||||
pub weights_type: WeightsType,
|
||||
pub weights_category: WeightsCategory,
|
||||
pub maybe_thumbnail_token: Option<String>,
|
||||
pub description_markdown: String,
|
||||
pub description_rendered_html: String,
|
||||
|
||||
@@ -40,9 +39,9 @@ pub struct RetrivedModelWeight {
|
||||
pub maybe_public_bucket_prefix: Option<String>,
|
||||
pub maybe_public_bucket_extension: Option<String>,
|
||||
|
||||
pub maybe_avatar_public_bucket_hash: Option<String>,
|
||||
pub maybe_avatar_public_bucket_prefix: Option<String>,
|
||||
pub maybe_avatar_public_bucket_extension: Option<String>,
|
||||
pub maybe_cover_image_public_bucket_hash: Option<String>,
|
||||
pub maybe_cover_image_public_bucket_prefix: Option<String>,
|
||||
pub maybe_cover_image_public_bucket_extension: Option<String>,
|
||||
|
||||
pub cached_user_ratings_negative_count: u32,
|
||||
pub cached_user_ratings_positive_count: u32,
|
||||
@@ -95,7 +94,6 @@ pub async fn get_weights_by_token_with_connection(
|
||||
title: record.title,
|
||||
weights_type: record.weights_type,
|
||||
weights_category: record.weights_category,
|
||||
maybe_thumbnail_token: record.maybe_thumbnail_token,
|
||||
description_markdown: record.description_markdown,
|
||||
description_rendered_html: record.description_rendered_html,
|
||||
creator_user_token: record.creator_user_token,
|
||||
@@ -112,9 +110,9 @@ pub async fn get_weights_by_token_with_connection(
|
||||
public_bucket_hash: record.public_bucket_hash,
|
||||
maybe_public_bucket_prefix: record.maybe_public_bucket_prefix,
|
||||
maybe_public_bucket_extension: record.maybe_public_bucket_extension,
|
||||
maybe_avatar_public_bucket_hash: record.maybe_avatar_public_bucket_hash,
|
||||
maybe_avatar_public_bucket_prefix: record.maybe_avatar_public_bucket_prefix,
|
||||
maybe_avatar_public_bucket_extension: record.maybe_avatar_public_bucket_extension,
|
||||
maybe_cover_image_public_bucket_hash: record.maybe_cover_image_public_bucket_hash,
|
||||
maybe_cover_image_public_bucket_prefix: record.maybe_cover_image_public_bucket_prefix,
|
||||
maybe_cover_image_public_bucket_extension: record.maybe_cover_image_public_bucket_extension,
|
||||
cached_user_ratings_negative_count: record.cached_user_ratings_negative_count,
|
||||
cached_user_ratings_positive_count: record.cached_user_ratings_positive_count,
|
||||
cached_user_ratings_total_count: record.cached_user_ratings_total_count,
|
||||
@@ -142,7 +140,6 @@ async fn select_include_deleted(
|
||||
wt.title,
|
||||
wt.weights_type as `weights_type: enums::by_table::model_weights::weights_types::WeightsType`,
|
||||
wt.weights_category as `weights_category: enums::by_table::model_weights::weights_category::WeightsCategory`,
|
||||
wt.maybe_thumbnail_token,
|
||||
wt.description_markdown,
|
||||
wt.description_rendered_html,
|
||||
|
||||
@@ -163,9 +160,9 @@ async fn select_include_deleted(
|
||||
wt.maybe_public_bucket_prefix,
|
||||
wt.maybe_public_bucket_extension,
|
||||
|
||||
avatar.public_bucket_directory_hash as maybe_avatar_public_bucket_hash,
|
||||
avatar.maybe_public_bucket_prefix as maybe_avatar_public_bucket_prefix,
|
||||
avatar.maybe_public_bucket_extension as maybe_avatar_public_bucket_extension,
|
||||
cover_image.public_bucket_directory_hash as maybe_cover_image_public_bucket_hash,
|
||||
cover_image.maybe_public_bucket_prefix as maybe_cover_image_public_bucket_prefix,
|
||||
cover_image.maybe_public_bucket_extension as maybe_cover_image_public_bucket_extension,
|
||||
|
||||
wt.cached_user_ratings_negative_count,
|
||||
wt.cached_user_ratings_positive_count,
|
||||
@@ -180,8 +177,8 @@ async fn select_include_deleted(
|
||||
FROM model_weights as wt
|
||||
JOIN users
|
||||
ON users.token = wt.creator_user_token
|
||||
LEFT OUTER JOIN media_files as avatar
|
||||
ON avatar.token = wt.maybe_avatar_media_file_token
|
||||
LEFT OUTER JOIN media_files as cover_image
|
||||
ON cover_image.token = wt.maybe_cover_image_media_file_token
|
||||
WHERE
|
||||
wt.token = ?
|
||||
"#,
|
||||
@@ -205,7 +202,6 @@ async fn select_without_deleted(
|
||||
wt.title,
|
||||
wt.weights_type as `weights_type: enums::by_table::model_weights::weights_types::WeightsType`,
|
||||
wt.weights_category as `weights_category: enums::by_table::model_weights::weights_category::WeightsCategory`,
|
||||
wt.maybe_thumbnail_token,
|
||||
wt.description_markdown,
|
||||
wt.description_rendered_html,
|
||||
wt.creator_ip_address,
|
||||
@@ -225,9 +221,9 @@ async fn select_without_deleted(
|
||||
wt.maybe_public_bucket_prefix,
|
||||
wt.maybe_public_bucket_extension,
|
||||
|
||||
avatar.public_bucket_directory_hash as maybe_avatar_public_bucket_hash,
|
||||
avatar.maybe_public_bucket_prefix as maybe_avatar_public_bucket_prefix,
|
||||
avatar.maybe_public_bucket_extension as maybe_avatar_public_bucket_extension,
|
||||
cover_image.public_bucket_directory_hash as maybe_cover_image_public_bucket_hash,
|
||||
cover_image.maybe_public_bucket_prefix as maybe_cover_image_public_bucket_prefix,
|
||||
cover_image.maybe_public_bucket_extension as maybe_cover_image_public_bucket_extension,
|
||||
|
||||
wt.cached_user_ratings_negative_count,
|
||||
wt.cached_user_ratings_positive_count,
|
||||
@@ -242,8 +238,8 @@ async fn select_without_deleted(
|
||||
FROM model_weights as wt
|
||||
JOIN users
|
||||
ON users.token = wt.creator_user_token
|
||||
LEFT OUTER JOIN media_files as avatar
|
||||
ON avatar.token = wt.maybe_avatar_media_file_token
|
||||
LEFT OUTER JOIN media_files as cover_image
|
||||
ON cover_image.token = wt.maybe_cover_image_media_file_token
|
||||
WHERE
|
||||
wt.token = ?
|
||||
AND wt.user_deleted_at IS NULL
|
||||
@@ -261,7 +257,6 @@ pub struct RawWeight {
|
||||
pub title: String,
|
||||
pub weights_type: WeightsType,
|
||||
pub weights_category: WeightsCategory,
|
||||
pub maybe_thumbnail_token: Option<String>,
|
||||
pub description_markdown: String,
|
||||
pub description_rendered_html: String,
|
||||
|
||||
@@ -281,9 +276,9 @@ pub struct RawWeight {
|
||||
pub maybe_public_bucket_prefix: Option<String>,
|
||||
pub maybe_public_bucket_extension: Option<String>,
|
||||
|
||||
pub maybe_avatar_public_bucket_hash: Option<String>,
|
||||
pub maybe_avatar_public_bucket_prefix: Option<String>,
|
||||
pub maybe_avatar_public_bucket_extension: Option<String>,
|
||||
pub maybe_cover_image_public_bucket_hash: Option<String>,
|
||||
pub maybe_cover_image_public_bucket_prefix: Option<String>,
|
||||
pub maybe_cover_image_public_bucket_extension: Option<String>,
|
||||
|
||||
pub cached_user_ratings_negative_count: u32,
|
||||
pub cached_user_ratings_positive_count: u32,
|
||||
|
||||
@@ -20,8 +20,6 @@ pub struct WeightsByTokensRecord {
|
||||
|
||||
pub title: String,
|
||||
|
||||
pub maybe_thumbnail_token: Option<String>,
|
||||
|
||||
pub creator_user_token: UserToken,
|
||||
pub creator_username: String,
|
||||
pub creator_display_name: String,
|
||||
@@ -31,9 +29,9 @@ pub struct WeightsByTokensRecord {
|
||||
pub maybe_public_bucket_prefix: Option<String>,
|
||||
pub maybe_public_bucket_extension: Option<String>,
|
||||
|
||||
pub maybe_avatar_public_bucket_hash: Option<String>,
|
||||
pub maybe_avatar_public_bucket_prefix: Option<String>,
|
||||
pub maybe_avatar_public_bucket_extension: Option<String>,
|
||||
pub maybe_cover_image_public_bucket_hash: Option<String>,
|
||||
pub maybe_cover_image_public_bucket_prefix: Option<String>,
|
||||
pub maybe_cover_image_public_bucket_extension: Option<String>,
|
||||
|
||||
pub cached_user_ratings_total_count: u32,
|
||||
pub cached_user_ratings_positive_count: u32,
|
||||
@@ -75,7 +73,6 @@ async fn get_raw_weights_by_tokens(
|
||||
mw.title,
|
||||
mw.weights_type,
|
||||
mw.weights_category,
|
||||
mw.maybe_thumbnail_token,
|
||||
users.token as creator_user_token,
|
||||
users.username as creator_username,
|
||||
users.display_name as creator_display_name,
|
||||
@@ -83,9 +80,9 @@ async fn get_raw_weights_by_tokens(
|
||||
mw.public_bucket_hash,
|
||||
mw.maybe_public_bucket_prefix,
|
||||
mw.maybe_public_bucket_extension,
|
||||
avatar.public_bucket_directory_hash as maybe_avatar_public_bucket_hash,
|
||||
avatar.maybe_public_bucket_prefix as maybe_avatar_public_bucket_prefix,
|
||||
avatar.maybe_public_bucket_extension as maybe_avatar_public_bucket_extension,
|
||||
cover_image.public_bucket_directory_hash as maybe_cover_image_public_bucket_hash,
|
||||
cover_image.maybe_public_bucket_prefix as maybe_cover_image_public_bucket_prefix,
|
||||
cover_image.maybe_public_bucket_extension as maybe_cover_image_public_bucket_extension,
|
||||
mw.cached_user_ratings_negative_count,
|
||||
mw.cached_user_ratings_positive_count,
|
||||
mw.cached_user_ratings_total_count,
|
||||
@@ -98,8 +95,8 @@ async fn get_raw_weights_by_tokens(
|
||||
FROM model_weights as mw
|
||||
JOIN users
|
||||
ON users.token = mw.creator_user_token
|
||||
LEFT OUTER JOIN media_files as avatar
|
||||
ON avatar.token = mw.maybe_avatar_media_file_token
|
||||
LEFT OUTER JOIN media_files as cover_image
|
||||
ON cover_image.token = mw.maybe_cover_image_media_file_token
|
||||
WHERE
|
||||
mw.creator_set_visibility = "public"
|
||||
AND mw.token IN (
|
||||
@@ -113,7 +110,6 @@ async fn get_raw_weights_by_tokens(
|
||||
mw.title,
|
||||
mw.weights_type,
|
||||
mw.weights_category,
|
||||
mw.maybe_thumbnail_token,
|
||||
users.token as creator_user_token,
|
||||
users.username as creator_username,
|
||||
users.display_name as creator_display_name,
|
||||
@@ -121,9 +117,9 @@ async fn get_raw_weights_by_tokens(
|
||||
mw.public_bucket_hash,
|
||||
mw.maybe_public_bucket_prefix,
|
||||
mw.maybe_public_bucket_extension,
|
||||
avatar.public_bucket_directory_hash as maybe_avatar_public_bucket_hash,
|
||||
avatar.maybe_public_bucket_prefix as maybe_avatar_public_bucket_prefix,
|
||||
avatar.maybe_public_bucket_extension as maybe_avatar_public_bucket_extension,
|
||||
cover_image.public_bucket_directory_hash as maybe_cover_image_public_bucket_hash,
|
||||
cover_image.maybe_public_bucket_prefix as maybe_cover_image_public_bucket_prefix,
|
||||
cover_image.maybe_public_bucket_extension as maybe_cover_image_public_bucket_extension,
|
||||
mw.cached_user_ratings_negative_count,
|
||||
mw.cached_user_ratings_positive_count,
|
||||
mw.cached_user_ratings_total_count,
|
||||
@@ -136,8 +132,8 @@ async fn get_raw_weights_by_tokens(
|
||||
FROM model_weights as mw
|
||||
JOIN users
|
||||
ON users.token = mw.creator_user_token
|
||||
LEFT OUTER JOIN media_files as avatar
|
||||
ON avatar.token = mw.maybe_avatar_media_file_token
|
||||
LEFT OUTER JOIN media_files as cover_image
|
||||
ON cover_image.token = mw.maybe_cover_image_media_file_token
|
||||
WHERE
|
||||
mw.creator_set_visibility = "public"
|
||||
AND mw.user_deleted_at IS NULL
|
||||
@@ -177,7 +173,6 @@ fn map_to_weights(dataset:Vec<RawWeightJoinUser>) -> Vec<WeightsByTokensRecord>
|
||||
title: weight.title,
|
||||
weights_type: weight.weights_type,
|
||||
weights_category: weight.weights_category,
|
||||
maybe_thumbnail_token: weight.maybe_thumbnail_token,
|
||||
|
||||
creator_user_token: weight.creator_user_token,
|
||||
creator_username: weight.creator_username,
|
||||
@@ -188,9 +183,9 @@ fn map_to_weights(dataset:Vec<RawWeightJoinUser>) -> Vec<WeightsByTokensRecord>
|
||||
maybe_public_bucket_prefix: weight.maybe_public_bucket_prefix,
|
||||
maybe_public_bucket_extension: weight.maybe_public_bucket_extension,
|
||||
|
||||
maybe_avatar_public_bucket_hash: weight.maybe_avatar_public_bucket_hash,
|
||||
maybe_avatar_public_bucket_prefix: weight.maybe_avatar_public_bucket_prefix,
|
||||
maybe_avatar_public_bucket_extension: weight.maybe_avatar_public_bucket_extension,
|
||||
maybe_cover_image_public_bucket_hash: weight.maybe_cover_image_public_bucket_hash,
|
||||
maybe_cover_image_public_bucket_prefix: weight.maybe_cover_image_public_bucket_prefix,
|
||||
maybe_cover_image_public_bucket_extension: weight.maybe_cover_image_public_bucket_extension,
|
||||
|
||||
cached_user_ratings_negative_count: weight.cached_user_ratings_negative_count,
|
||||
cached_user_ratings_positive_count: weight.cached_user_ratings_positive_count,
|
||||
@@ -218,8 +213,6 @@ fn map_to_weights(dataset:Vec<RawWeightJoinUser>) -> Vec<WeightsByTokensRecord>
|
||||
|
||||
pub title: String,
|
||||
|
||||
pub maybe_thumbnail_token: Option<String>,
|
||||
|
||||
pub creator_user_token: UserToken,
|
||||
pub creator_username: String,
|
||||
pub creator_display_name: String,
|
||||
@@ -229,9 +222,9 @@ fn map_to_weights(dataset:Vec<RawWeightJoinUser>) -> Vec<WeightsByTokensRecord>
|
||||
pub maybe_public_bucket_prefix: Option<String>,
|
||||
pub maybe_public_bucket_extension: Option<String>,
|
||||
|
||||
pub maybe_avatar_public_bucket_hash: Option<String>,
|
||||
pub maybe_avatar_public_bucket_prefix: Option<String>,
|
||||
pub maybe_avatar_public_bucket_extension: Option<String>,
|
||||
pub maybe_cover_image_public_bucket_hash: Option<String>,
|
||||
pub maybe_cover_image_public_bucket_prefix: Option<String>,
|
||||
pub maybe_cover_image_public_bucket_extension: Option<String>,
|
||||
|
||||
pub cached_user_ratings_total_count: u32,
|
||||
pub cached_user_ratings_positive_count: u32,
|
||||
@@ -264,7 +257,6 @@ impl FromRow<'_, MySqlRow> for RawWeightJoinUser {
|
||||
weights_type: WeightsType::try_from_mysql_row(row, "weights_type")?,
|
||||
weights_category: WeightsCategory::try_from_mysql_row(row, "weights_category")?,
|
||||
title: row.try_get("title")?,
|
||||
maybe_thumbnail_token: row.try_get("maybe_thumbnail_token")?,
|
||||
creator_user_token: UserToken::new_from_str(row.try_get("creator_user_token")?),
|
||||
creator_username: row.try_get("creator_username")?,
|
||||
creator_display_name: row.try_get("creator_display_name")?,
|
||||
@@ -272,9 +264,9 @@ impl FromRow<'_, MySqlRow> for RawWeightJoinUser {
|
||||
public_bucket_hash: row.try_get("public_bucket_hash")?,
|
||||
maybe_public_bucket_prefix: row.try_get("maybe_public_bucket_prefix")?,
|
||||
maybe_public_bucket_extension: row.try_get("maybe_public_bucket_extension")?,
|
||||
maybe_avatar_public_bucket_hash: row.try_get("maybe_avatar_public_bucket_hash")?,
|
||||
maybe_avatar_public_bucket_prefix: row.try_get("maybe_avatar_public_bucket_prefix")?,
|
||||
maybe_avatar_public_bucket_extension: row.try_get("maybe_avatar_public_bucket_extension")?,
|
||||
maybe_cover_image_public_bucket_hash: row.try_get("maybe_cover_image_public_bucket_hash")?,
|
||||
maybe_cover_image_public_bucket_prefix: row.try_get("maybe_cover_image_public_bucket_prefix")?,
|
||||
maybe_cover_image_public_bucket_extension: row.try_get("maybe_cover_image_public_bucket_extension")?,
|
||||
cached_user_ratings_total_count: row.try_get("cached_user_ratings_total_count")?,
|
||||
cached_user_ratings_positive_count: row.try_get("cached_user_ratings_positive_count")?,
|
||||
cached_user_ratings_negative_count: row.try_get("cached_user_ratings_negative_count")?,
|
||||
|
||||
@@ -31,8 +31,6 @@ pub struct WeightsJoinUserRecord {
|
||||
|
||||
pub title: String,
|
||||
|
||||
pub maybe_thumbnail_token: Option<String>,
|
||||
|
||||
pub description_markdown: String,
|
||||
pub description_rendered_html: String,
|
||||
|
||||
@@ -52,9 +50,9 @@ pub struct WeightsJoinUserRecord {
|
||||
pub maybe_public_bucket_prefix: Option<String>,
|
||||
pub maybe_public_bucket_extension: Option<String>,
|
||||
|
||||
pub maybe_avatar_public_bucket_hash: Option<String>,
|
||||
pub maybe_avatar_public_bucket_prefix: Option<String>,
|
||||
pub maybe_avatar_public_bucket_extension: Option<String>,
|
||||
pub maybe_cover_image_public_bucket_hash: Option<String>,
|
||||
pub maybe_cover_image_public_bucket_prefix: Option<String>,
|
||||
pub maybe_cover_image_public_bucket_extension: Option<String>,
|
||||
|
||||
pub cached_user_ratings_total_count: u32,
|
||||
pub cached_user_ratings_positive_count: u32,
|
||||
@@ -142,7 +140,6 @@ fn select_result_fields() -> String {
|
||||
mw.title,
|
||||
mw.weights_type,
|
||||
mw.weights_category,
|
||||
mw.maybe_thumbnail_token,
|
||||
mw.description_markdown,
|
||||
mw.description_rendered_html,
|
||||
u.token as creator_user_token,
|
||||
@@ -161,9 +158,9 @@ fn select_result_fields() -> String {
|
||||
mw.maybe_public_bucket_prefix,
|
||||
mw.maybe_public_bucket_extension,
|
||||
|
||||
avatar.public_bucket_directory_hash as maybe_avatar_public_bucket_hash,
|
||||
avatar.maybe_public_bucket_prefix as maybe_avatar_public_bucket_prefix,
|
||||
avatar.maybe_public_bucket_extension as maybe_avatar_public_bucket_extension,
|
||||
cover_image.public_bucket_directory_hash as maybe_cover_image_public_bucket_hash,
|
||||
cover_image.maybe_public_bucket_prefix as maybe_cover_image_public_bucket_prefix,
|
||||
cover_image.maybe_public_bucket_extension as maybe_cover_image_public_bucket_extension,
|
||||
|
||||
mw.cached_user_ratings_negative_count,
|
||||
mw.cached_user_ratings_positive_count,
|
||||
@@ -196,8 +193,8 @@ SELECT
|
||||
FROM model_weights as mw
|
||||
JOIN users as u
|
||||
ON u.token = mw.creator_user_token
|
||||
LEFT OUTER JOIN media_files as avatar
|
||||
ON avatar.token = mw.maybe_avatar_media_file_token
|
||||
LEFT OUTER JOIN media_files as cover_image
|
||||
ON cover_image.token = mw.maybe_cover_image_media_file_token
|
||||
"#
|
||||
));
|
||||
|
||||
@@ -233,7 +230,6 @@ async fn map_to_weights(dataset:Vec<RawWeightJoinUser>) -> Vec<WeightsJoinUserRe
|
||||
title: weight.title,
|
||||
weights_type: weight.weights_type,
|
||||
weights_category: weight.weights_category,
|
||||
maybe_thumbnail_token: weight.maybe_thumbnail_token,
|
||||
description_markdown: weight.description_markdown,
|
||||
description_rendered_html: weight.description_rendered_html,
|
||||
|
||||
@@ -250,9 +246,9 @@ async fn map_to_weights(dataset:Vec<RawWeightJoinUser>) -> Vec<WeightsJoinUserRe
|
||||
maybe_public_bucket_prefix: weight.maybe_public_bucket_prefix,
|
||||
maybe_public_bucket_extension: weight.maybe_public_bucket_extension,
|
||||
|
||||
maybe_avatar_public_bucket_hash: weight.maybe_avatar_public_bucket_hash,
|
||||
maybe_avatar_public_bucket_prefix: weight.maybe_avatar_public_bucket_prefix,
|
||||
maybe_avatar_public_bucket_extension: weight.maybe_avatar_public_bucket_extension,
|
||||
maybe_cover_image_public_bucket_hash: weight.maybe_cover_image_public_bucket_hash,
|
||||
maybe_cover_image_public_bucket_prefix: weight.maybe_cover_image_public_bucket_prefix,
|
||||
maybe_cover_image_public_bucket_extension: weight.maybe_cover_image_public_bucket_extension,
|
||||
|
||||
cached_user_ratings_negative_count: weight.cached_user_ratings_negative_count,
|
||||
cached_user_ratings_positive_count: weight.cached_user_ratings_positive_count,
|
||||
@@ -284,8 +280,6 @@ async fn map_to_weights(dataset:Vec<RawWeightJoinUser>) -> Vec<WeightsJoinUserRe
|
||||
|
||||
pub title: String,
|
||||
|
||||
pub maybe_thumbnail_token: Option<String>,
|
||||
|
||||
pub description_markdown: String,
|
||||
pub description_rendered_html: String,
|
||||
|
||||
@@ -305,9 +299,9 @@ async fn map_to_weights(dataset:Vec<RawWeightJoinUser>) -> Vec<WeightsJoinUserRe
|
||||
pub maybe_public_bucket_prefix: Option<String>,
|
||||
pub maybe_public_bucket_extension: Option<String>,
|
||||
|
||||
pub maybe_avatar_public_bucket_hash: Option<String>,
|
||||
pub maybe_avatar_public_bucket_prefix: Option<String>,
|
||||
pub maybe_avatar_public_bucket_extension: Option<String>,
|
||||
pub maybe_cover_image_public_bucket_hash: Option<String>,
|
||||
pub maybe_cover_image_public_bucket_prefix: Option<String>,
|
||||
pub maybe_cover_image_public_bucket_extension: Option<String>,
|
||||
|
||||
pub cached_user_ratings_total_count: u32,
|
||||
pub cached_user_ratings_positive_count: u32,
|
||||
@@ -335,7 +329,6 @@ impl FromRow<'_, MySqlRow> for RawWeightJoinUser {
|
||||
weights_type: row.try_get("weights_type")?,
|
||||
weights_category: row.try_get("weights_category")?,
|
||||
title: row.try_get("title")?,
|
||||
maybe_thumbnail_token: row.try_get("maybe_thumbnail_token")?,
|
||||
description_markdown: row.try_get("description_markdown")?,
|
||||
description_rendered_html: row.try_get("description_rendered_html")?,
|
||||
creator_user_token: row.try_get("creator_user_token")?,
|
||||
@@ -349,9 +342,9 @@ impl FromRow<'_, MySqlRow> for RawWeightJoinUser {
|
||||
public_bucket_hash: row.try_get("public_bucket_hash")?,
|
||||
maybe_public_bucket_prefix: row.try_get("maybe_public_bucket_prefix")?,
|
||||
maybe_public_bucket_extension: row.try_get("maybe_public_bucket_extension")?,
|
||||
maybe_avatar_public_bucket_hash: row.try_get("maybe_avatar_public_bucket_hash")?,
|
||||
maybe_avatar_public_bucket_prefix: row.try_get("maybe_avatar_public_bucket_prefix")?,
|
||||
maybe_avatar_public_bucket_extension: row.try_get("maybe_avatar_public_bucket_extension")?,
|
||||
maybe_cover_image_public_bucket_hash: row.try_get("maybe_cover_image_public_bucket_hash")?,
|
||||
maybe_cover_image_public_bucket_prefix: row.try_get("maybe_cover_image_public_bucket_prefix")?,
|
||||
maybe_cover_image_public_bucket_extension: row.try_get("maybe_cover_image_public_bucket_extension")?,
|
||||
cached_user_ratings_total_count: row.try_get("cached_user_ratings_total_count")?,
|
||||
cached_user_ratings_positive_count: row.try_get("cached_user_ratings_positive_count")?,
|
||||
cached_user_ratings_negative_count: row.try_get("cached_user_ratings_negative_count")?,
|
||||
|
||||
+14
-20
@@ -36,8 +36,6 @@ pub struct WeightJoinUser {
|
||||
|
||||
pub title: String,
|
||||
|
||||
pub maybe_thumbnail_token: Option<String>,
|
||||
|
||||
pub description_markdown: String,
|
||||
pub description_rendered_html: String,
|
||||
|
||||
@@ -57,9 +55,9 @@ pub struct WeightJoinUser {
|
||||
pub maybe_public_bucket_prefix: Option<String>,
|
||||
pub maybe_public_bucket_extension: Option<String>,
|
||||
|
||||
pub maybe_avatar_public_bucket_hash: Option<String>,
|
||||
pub maybe_avatar_public_bucket_prefix: Option<String>,
|
||||
pub maybe_avatar_public_bucket_extension: Option<String>,
|
||||
pub maybe_cover_image_public_bucket_hash: Option<String>,
|
||||
pub maybe_cover_image_public_bucket_prefix: Option<String>,
|
||||
pub maybe_cover_image_public_bucket_extension: Option<String>,
|
||||
|
||||
pub cached_user_ratings_total_count: u32,
|
||||
pub cached_user_ratings_positive_count: u32,
|
||||
@@ -220,7 +218,6 @@ impl ListWeightsQueryBuilder {
|
||||
record.weights_category.as_str()
|
||||
).unwrap(),
|
||||
title: record.title,
|
||||
maybe_thumbnail_token: record.maybe_thumbnail_token,
|
||||
description_markdown: record.description_markdown,
|
||||
description_rendered_html: record.description_rendered_html,
|
||||
creator_user_token: UserToken::new_from_str(&record.creator_user_token),
|
||||
@@ -238,9 +235,9 @@ impl ListWeightsQueryBuilder {
|
||||
public_bucket_hash: record.public_bucket_hash,
|
||||
maybe_public_bucket_prefix: record.maybe_public_bucket_prefix,
|
||||
maybe_public_bucket_extension: record.maybe_public_bucket_extension,
|
||||
maybe_avatar_public_bucket_hash: record.maybe_avatar_public_bucket_hash,
|
||||
maybe_avatar_public_bucket_prefix: record.maybe_avatar_public_bucket_prefix,
|
||||
maybe_avatar_public_bucket_extension: record.maybe_avatar_public_bucket_extension,
|
||||
maybe_cover_image_public_bucket_hash: record.maybe_cover_image_public_bucket_hash,
|
||||
maybe_cover_image_public_bucket_prefix: record.maybe_cover_image_public_bucket_prefix,
|
||||
maybe_cover_image_public_bucket_extension: record.maybe_cover_image_public_bucket_extension,
|
||||
cached_user_ratings_total_count: record.cached_user_ratings_total_count,
|
||||
cached_user_ratings_positive_count: record.cached_user_ratings_positive_count,
|
||||
cached_user_ratings_negative_count: record.cached_user_ratings_negative_count,
|
||||
@@ -275,7 +272,6 @@ impl ListWeightsQueryBuilder {
|
||||
model_weights.weights_type,
|
||||
model_weights.weights_category,
|
||||
model_weights.title,
|
||||
model_weights.maybe_thumbnail_token,
|
||||
model_weights.description_markdown,
|
||||
model_weights.description_rendered_html,
|
||||
model_weights.creator_user_token,
|
||||
@@ -289,9 +285,9 @@ impl ListWeightsQueryBuilder {
|
||||
model_weights.public_bucket_hash,
|
||||
model_weights.maybe_public_bucket_prefix,
|
||||
model_weights.maybe_public_bucket_extension,
|
||||
avatar.public_bucket_directory_hash as maybe_avatar_public_bucket_hash,
|
||||
avatar.maybe_public_bucket_prefix as maybe_avatar_public_bucket_prefix,
|
||||
avatar.maybe_public_bucket_extension as maybe_avatar_public_bucket_extension,
|
||||
cover_image.public_bucket_directory_hash as maybe_cover_image_public_bucket_hash,
|
||||
cover_image.maybe_public_bucket_prefix as maybe_cover_image_public_bucket_prefix,
|
||||
cover_image.maybe_public_bucket_extension as maybe_cover_image_public_bucket_extension,
|
||||
model_weights.cached_user_ratings_total_count,
|
||||
model_weights.cached_user_ratings_positive_count,
|
||||
model_weights.cached_user_ratings_negative_count,
|
||||
@@ -308,8 +304,8 @@ impl ListWeightsQueryBuilder {
|
||||
FROM model_weights
|
||||
JOIN users
|
||||
ON users.token = model_weights.creator_user_token
|
||||
LEFT OUTER JOIN media_files as avatar
|
||||
ON avatar.token = model_weights.maybe_avatar_media_file_token
|
||||
LEFT OUTER JOIN media_files as cover_image
|
||||
ON cover_image.token = model_weights.maybe_cover_image_media_file_token
|
||||
"#.to_string();
|
||||
|
||||
query.push_str(&self.build_predicates());
|
||||
@@ -434,8 +430,6 @@ struct RawWeightJoinUser {
|
||||
|
||||
pub title: String,
|
||||
|
||||
pub maybe_thumbnail_token: Option<String>,
|
||||
|
||||
pub description_markdown: String,
|
||||
pub description_rendered_html: String,
|
||||
|
||||
@@ -455,9 +449,9 @@ struct RawWeightJoinUser {
|
||||
pub maybe_public_bucket_prefix: Option<String>,
|
||||
pub maybe_public_bucket_extension: Option<String>,
|
||||
|
||||
pub maybe_avatar_public_bucket_hash: Option<String>,
|
||||
pub maybe_avatar_public_bucket_prefix: Option<String>,
|
||||
pub maybe_avatar_public_bucket_extension: Option<String>,
|
||||
pub maybe_cover_image_public_bucket_hash: Option<String>,
|
||||
pub maybe_cover_image_public_bucket_prefix: Option<String>,
|
||||
pub maybe_cover_image_public_bucket_extension: Option<String>,
|
||||
|
||||
pub cached_user_ratings_total_count: u32,
|
||||
pub cached_user_ratings_positive_count: u32,
|
||||
|
||||
+2
-6
@@ -76,9 +76,7 @@ SET
|
||||
weights_type = ?,
|
||||
weights_category = ?,
|
||||
title = ?,
|
||||
maybe_thumbnail_token = NULL,
|
||||
maybe_avatar_media_file_token = NULL,
|
||||
maybe_cover_media_file_token = NULL,
|
||||
maybe_cover_image_media_file_token = NULL,
|
||||
description_markdown = ?,
|
||||
description_rendered_html = ?,
|
||||
creator_user_token = ?,
|
||||
@@ -111,9 +109,7 @@ ON DUPLICATE KEY UPDATE
|
||||
weights_type = ?,
|
||||
weights_category = ?,
|
||||
title = ?,
|
||||
maybe_thumbnail_token = NULL,
|
||||
maybe_avatar_media_file_token = NULL,
|
||||
maybe_cover_media_file_token = NULL,
|
||||
maybe_cover_image_media_file_token = NULL,
|
||||
description_markdown = ?,
|
||||
description_rendered_html = ?,
|
||||
creator_user_token = ?,
|
||||
|
||||
@@ -4,7 +4,6 @@ CREATE TABLE model_weights (
|
||||
weights_type VARCHAR(32) NOT NULL,
|
||||
weights_category VARCHAR(32) NOT NULL,
|
||||
title VARCHAR(255) NOT NULL,
|
||||
maybe_thumbnail_token VARCHAR(32) DEFAULT NULL,
|
||||
description_markdown TEXT NOT NULL,
|
||||
description_rendered_html TEXT NOT NULL,
|
||||
creator_user_token VARCHAR(32) NOT NULL,
|
||||
|
||||
@@ -65,7 +65,6 @@ mod tests {
|
||||
weights_type: WeightsType::RvcV2, // replace with actual WeightsType
|
||||
weights_category: WeightsCategory::VoiceConversion, // replace with actual WeightsCategory
|
||||
title: "Title 1".to_string(),
|
||||
maybe_thumbnail_token: Some("Thumbnail 1".to_string()),
|
||||
description_markdown: "Description 1".to_string(),
|
||||
description_rendered_html: "<p>Description 1</p>".to_string(),
|
||||
creator_user_token: Some(&creator_token1), // replace with actual UserToken
|
||||
@@ -98,7 +97,6 @@ mod tests {
|
||||
assert_eq!(result.title, "Title 1".to_string());
|
||||
assert_eq!(result.weights_type, WeightsType::RvcV2);
|
||||
assert_eq!(result.weights_category, WeightsCategory::VoiceConversion);
|
||||
assert_eq!(result.maybe_thumbnail_token, Some("Thumbnail 1".to_string()));
|
||||
assert_eq!(result.description_markdown, "Description 1".to_string());
|
||||
assert_eq!(result.description_rendered_html, "<p>Description 1</p>".to_string());
|
||||
assert_eq!(result.creator_user_token, creator_token1);
|
||||
@@ -140,7 +138,6 @@ mod tests {
|
||||
weights_type: WeightsType::RvcV2, // replace with actual WeightsType
|
||||
weights_category: WeightsCategory::VoiceConversion, // replace with actual WeightsCategory
|
||||
title: "Title 1".to_string(),
|
||||
maybe_thumbnail_token: Some("Thumbnail 1".to_string()),
|
||||
description_markdown: "Description 1".to_string(),
|
||||
description_rendered_html: "<p>Description 1</p>".to_string(),
|
||||
creator_user_token: Some(&creator_token1), // replace with actual UserToken
|
||||
@@ -217,7 +214,6 @@ mod tests {
|
||||
weights_type: WeightsType::RvcV2, // replace with actual WeightsType
|
||||
weights_category: WeightsCategory::VoiceConversion, // replace with actual WeightsCategory
|
||||
title: "Title 1".to_string(),
|
||||
maybe_thumbnail_token: Some("Thumbnail 1".to_string()),
|
||||
description_markdown: "Description 1".to_string(),
|
||||
description_rendered_html: "<p>Description 1</p>".to_string(),
|
||||
creator_user_token: Some(&creator_token1), // replace with actual UserToken
|
||||
@@ -332,7 +328,6 @@ mod tests {
|
||||
weights_type: weights_type, // replace with actual WeightsType
|
||||
weights_category: weights_category, // replace with actual WeightsCategory
|
||||
title: format!("Title {}", i),
|
||||
maybe_thumbnail_token: Some(format!("Thumbnail {}", i)),
|
||||
description_markdown: format!("Description {}", i),
|
||||
description_rendered_html: format!("<p>Description {}</p>", i),
|
||||
creator_user_token: Some(&creator_token), // replace with actual UserToken
|
||||
@@ -575,7 +570,6 @@ mod tests {
|
||||
weights_type: weights_type, // replace with actual WeightsType
|
||||
weights_category: weights_category, // replace with actual WeightsCategory
|
||||
title: format!("Title {}", i),
|
||||
maybe_thumbnail_token: Some(format!("Thumbnail {}", i)),
|
||||
description_markdown: format!("Description {}", i),
|
||||
description_rendered_html: format!("<p>Description {}</p>", i),
|
||||
creator_user_token: Some(&creator_token), // replace with actual UserToken
|
||||
|
||||
-119
@@ -1,119 +0,0 @@
|
||||
use std::collections::HashSet;
|
||||
use std::sync::Arc;
|
||||
|
||||
use actix_multipart::Multipart;
|
||||
use actix_web::{HttpRequest, HttpResponse, web};
|
||||
use enums::by_table::model_weights::weights_category::WeightsCategory;
|
||||
use enums::by_table::model_weights::weights_types::WeightsType;
|
||||
use mysql_queries::queries::model_weights::create_weight::{self, create_weight};
|
||||
use once_cell::sync::Lazy;
|
||||
|
||||
use tokens::tokens::model_weights::ModelWeightToken;
|
||||
|
||||
use crate::http_server::endpoints::media_uploads::common::upload_error::UploadError;
|
||||
use crate::server_state::ServerState;
|
||||
|
||||
use log::{error, info, warn};
|
||||
|
||||
use buckets::public::weight_uploads::original_file::WeightUploadOriginalFilePath;
|
||||
use enums::by_table::media_uploads::media_upload_source::MediaUploadSource;
|
||||
use enums::by_table::media_uploads::media_upload_type::MediaUploadType;
|
||||
use enums::common::visibility::Visibility;
|
||||
use hashing::sha256::sha256_hash_bytes::sha256_hash_bytes;
|
||||
use http_server_common::request::get_request_ip::get_request_ip;
|
||||
use media::decode_basic_audio_info::decode_basic_audio_bytes_info;
|
||||
use mimetypes::mimetype_for_bytes::get_mimetype_for_bytes;
|
||||
use mysql_queries::queries::media_uploads::get_media_upload_by_uuid::get_media_upload_by_uuid_with_connection;
|
||||
use mysql_queries::queries::media_uploads::insert_media_upload::{Args, insert_media_upload};
|
||||
|
||||
use crate::http_server::endpoints::media_uploads::common::drain_multipart_request::{drain_multipart_request, MediaSource};
|
||||
use crate::validations::validate_idempotency_token_format::validate_idempotency_token_format;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
#[derive(Serialize,ToSchema)]
|
||||
pub struct UploadWeightsSuccessResponse {
|
||||
pub success: bool,
|
||||
pub upload_token: ModelWeightToken,
|
||||
}
|
||||
|
||||
static ALLOWED_MIME_TYPES : Lazy<HashSet<&'static str>> = Lazy::new(|| {
|
||||
HashSet::from([
|
||||
"binary/octet-stream",
|
||||
])
|
||||
});
|
||||
|
||||
// pub async fn create_weight_handler(
|
||||
// http_request: HttpRequest,
|
||||
// server_state: web::Data<Arc<ServerState>>,
|
||||
// mut multipart_payload: Multipart,
|
||||
// ) -> Result<HttpResponse, UploadError> {
|
||||
|
||||
|
||||
// let weight_upload_token = response.to_model_token();
|
||||
|
||||
// let response: UploadWeightsSuccessResponse = UploadWeightsSuccessResponse {
|
||||
// success: true,
|
||||
// upload_token: weight_upload_token,
|
||||
// };
|
||||
|
||||
// let body = serde_json::to_string(&response)
|
||||
// .map_err(|e| UploadError::ServerError)?;
|
||||
|
||||
// return Ok(HttpResponse::Ok()
|
||||
// .content_type("application/json")
|
||||
// .body(body));
|
||||
// }
|
||||
|
||||
// pub enum SuccessCase {
|
||||
// WeightAlreadyUploaded {
|
||||
// existing_upload_token: ModelWeightToken,
|
||||
// },
|
||||
// WeightSuccessfullyUploaded {
|
||||
// upload_token: ModelWeightToken,
|
||||
// }
|
||||
// }
|
||||
|
||||
// impl SuccessCase {
|
||||
// pub fn to_model_token(self) -> ModelWeightToken {
|
||||
// match self {
|
||||
// SuccessCase::WeightAlreadyUploaded { existing_upload_token } => existing_upload_token,
|
||||
// SuccessCase::WeightSuccessfullyUploaded { upload_token } => upload_token,
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// let token = create_weight(CreateModelWeightsArgs {
|
||||
// token: &ModelWeightToken::generate(),
|
||||
// weights_type: WeightsType::LoRA, // to do parse multi part for this
|
||||
// weights_category: WeightsCategory::ImageGeneration,
|
||||
// title: upload_weights_request.file_name.as_deref(),
|
||||
// maybe_thumbnail_token: &ThumbnailToken::generate(),
|
||||
// description_markdown: "",
|
||||
// description_rendered_html: "",
|
||||
// creator_user_token: maybe_user_token.as_str(),
|
||||
// creator_ip_address: &ip_address,
|
||||
// creator_set_visibility,
|
||||
// maybe_last_update_user_token: "",
|
||||
// original_download_url: "",
|
||||
// original_filename: upload_weights_request.file_name.as_deref(),
|
||||
// file_size_bytes: file_size_bytes as i32,
|
||||
// file_checksum_sha2: hash,
|
||||
// private_bucket_hash: private_bucket_hash,
|
||||
// maybe_private_bucket_prefix: None,
|
||||
// maybe_private_bucket_extension: None,
|
||||
// cached_user_ratings_total_count: 0,
|
||||
// cached_user_ratings_positive_count: 0,
|
||||
// cached_user_ratings_negative_count: 0,
|
||||
// maybe_cached_user_ratings_ratio: None,
|
||||
// version: 0,
|
||||
// mysql_pool: &server_state.mysql_pool,
|
||||
// }).await
|
||||
// .map_err(|e| {
|
||||
// error!("Error creating weights upload: {:?}", e);
|
||||
// UploadError::ServerError
|
||||
// })?;
|
||||
|
||||
// info!("new weights upload id: {} token: {:?}", record_id, &token);
|
||||
|
||||
// Ok()
|
||||
// }
|
||||
@@ -26,7 +26,6 @@ pub struct GetWeightResponse {
|
||||
title: String,
|
||||
weights_type: WeightsType,
|
||||
weights_category: WeightsCategory,
|
||||
maybe_thumbnail_token: Option<String>,
|
||||
description_markdown: String,
|
||||
description_rendered_html: String,
|
||||
|
||||
@@ -36,9 +35,9 @@ pub struct GetWeightResponse {
|
||||
file_size_bytes: i32,
|
||||
file_checksum_sha2: String,
|
||||
|
||||
/// Avatars are small descriptive images that can be set for any model.
|
||||
/// If an avatar is set, this is the path to the asset.
|
||||
maybe_avatar_public_bucket_path: Option<String>,
|
||||
/// Cover images are small descriptive images that can be set for any model.
|
||||
/// If a cover image is set, this is the path to the asset.
|
||||
maybe_cover_image_public_bucket_path: Option<String>,
|
||||
|
||||
cached_user_ratings_negative_count: u32,
|
||||
cached_user_ratings_positive_count: u32,
|
||||
@@ -144,13 +143,13 @@ pub async fn get_weight_handler(
|
||||
return Err(GetWeightError::NotAuthorized);
|
||||
}
|
||||
|
||||
let maybe_avatar = weight.maybe_avatar_public_bucket_hash
|
||||
let maybe_cover_image = weight.maybe_cover_image_public_bucket_hash
|
||||
.as_deref()
|
||||
.map(|hash| {
|
||||
MediaFileBucketPath::from_object_hash(
|
||||
hash,
|
||||
weight.maybe_avatar_public_bucket_prefix.as_deref(),
|
||||
weight.maybe_avatar_public_bucket_extension.as_deref())
|
||||
weight.maybe_cover_image_public_bucket_prefix.as_deref(),
|
||||
weight.maybe_cover_image_public_bucket_extension.as_deref())
|
||||
.get_full_object_path_str()
|
||||
.to_string()
|
||||
});
|
||||
@@ -168,10 +167,9 @@ pub async fn get_weight_handler(
|
||||
title: weight.title,
|
||||
weights_type: weight.weights_type,
|
||||
weights_category: weight.weights_category,
|
||||
maybe_thumbnail_token: weight.maybe_thumbnail_token,
|
||||
description_markdown: weight.description_markdown,
|
||||
description_rendered_html: weight.description_rendered_html,
|
||||
maybe_avatar_public_bucket_path: maybe_avatar,
|
||||
maybe_cover_image_public_bucket_path: maybe_cover_image,
|
||||
creator,
|
||||
creator_set_visibility: weight.creator_set_visibility,
|
||||
file_size_bytes: weight.file_size_bytes,
|
||||
|
||||
+7
-7
@@ -53,9 +53,9 @@ pub struct ModelWeightForList {
|
||||
pub description_markdown: String,
|
||||
pub description_rendered_html: String,
|
||||
|
||||
/// Avatars are small descriptive images that can be set for any model.
|
||||
/// If an avatar is set, this is the path to the asset.
|
||||
pub maybe_avatar_public_bucket_path: Option<String>,
|
||||
/// Cover images are small descriptive images that can be set for any model.
|
||||
/// If a cover image is set, this is the path to the asset.
|
||||
pub maybe_cover_image_public_bucket_path: Option<String>,
|
||||
|
||||
pub creator: UserDetailsLight,
|
||||
pub creator_set_visibility: Visibility,
|
||||
@@ -226,13 +226,13 @@ pub async fn list_available_weights_handler(
|
||||
weights: weights_page.weights.into_iter()
|
||||
.map(|weight| {
|
||||
|
||||
let maybe_avatar = weight.maybe_avatar_public_bucket_hash
|
||||
let maybe_cover_image = weight.maybe_cover_image_public_bucket_hash
|
||||
.as_deref()
|
||||
.map(|hash| {
|
||||
MediaFileBucketPath::from_object_hash(
|
||||
hash,
|
||||
weight.maybe_avatar_public_bucket_prefix.as_deref(),
|
||||
weight.maybe_avatar_public_bucket_extension.as_deref())
|
||||
weight.maybe_cover_image_public_bucket_prefix.as_deref(),
|
||||
weight.maybe_cover_image_public_bucket_extension.as_deref())
|
||||
.get_full_object_path_str()
|
||||
.to_string()
|
||||
});
|
||||
@@ -245,7 +245,7 @@ pub async fn list_available_weights_handler(
|
||||
|
||||
description_markdown: weight.description_markdown,
|
||||
description_rendered_html: weight.description_rendered_html,
|
||||
maybe_avatar_public_bucket_path: maybe_avatar,
|
||||
maybe_cover_image_public_bucket_path: maybe_cover_image,
|
||||
|
||||
creator: UserDetailsLight::from_db_fields(
|
||||
&weight.creator_user_token,
|
||||
|
||||
+7
-7
@@ -36,9 +36,9 @@ pub struct ModelWeightForList {
|
||||
|
||||
pub creator: UserDetailsLight,
|
||||
|
||||
/// Avatars are small descriptive images that can be set for any model.
|
||||
/// If an avatar is set, this is the path to the asset.
|
||||
pub maybe_avatar_public_bucket_path: Option<String>,
|
||||
/// Cover images are small descriptive images that can be set for any model.
|
||||
/// If a cover image is set, this is the path to the asset.
|
||||
pub maybe_cover_image_public_bucket_path: Option<String>,
|
||||
|
||||
pub cached_user_ratings_total_count: u32,
|
||||
pub cached_user_ratings_positive_count: u32,
|
||||
@@ -130,13 +130,13 @@ pub async fn list_featured_weights_handler(
|
||||
weights: weights.into_iter()
|
||||
.map(|w| {
|
||||
|
||||
let maybe_avatar = w.maybe_avatar_public_bucket_hash
|
||||
let maybe_cover_image = w.maybe_cover_image_public_bucket_hash
|
||||
.as_deref()
|
||||
.map(|hash| {
|
||||
MediaFileBucketPath::from_object_hash(
|
||||
hash,
|
||||
w.maybe_avatar_public_bucket_prefix.as_deref(),
|
||||
w.maybe_avatar_public_bucket_extension.as_deref())
|
||||
w.maybe_cover_image_public_bucket_prefix.as_deref(),
|
||||
w.maybe_cover_image_public_bucket_extension.as_deref())
|
||||
.get_full_object_path_str()
|
||||
.to_string()
|
||||
});
|
||||
@@ -146,7 +146,7 @@ pub async fn list_featured_weights_handler(
|
||||
title: w.title,
|
||||
weights_type: w.weights_type,
|
||||
weights_category: w.weights_category,
|
||||
maybe_avatar_public_bucket_path: maybe_avatar,
|
||||
maybe_cover_image_public_bucket_path: maybe_cover_image,
|
||||
creator: UserDetailsLight::from_db_fields(
|
||||
&w.creator_user_token,
|
||||
&w.creator_username,
|
||||
|
||||
+7
-7
@@ -32,9 +32,9 @@ pub struct Weight {
|
||||
file_size_bytes: i32,
|
||||
file_checksum_sha2: String,
|
||||
|
||||
/// Avatars are small descriptive images that can be set for any model.
|
||||
/// If an avatar is set, this is the path to the asset.
|
||||
maybe_avatar_public_bucket_path: Option<String>,
|
||||
/// Cover images are small descriptive images that can be set for any model.
|
||||
/// If a cover image is set, this is the path to the asset.
|
||||
maybe_cover_image_public_bucket_path: Option<String>,
|
||||
|
||||
cached_user_ratings_total_count: u32,
|
||||
cached_user_ratings_positive_count: u32,
|
||||
@@ -156,13 +156,13 @@ pub async fn list_weights_by_user_handler(
|
||||
|
||||
let weights:Vec<Weight> = results_page.records.into_iter().map(|weight| {
|
||||
|
||||
let maybe_avatar = weight.maybe_avatar_public_bucket_hash
|
||||
let maybe_cover_image = weight.maybe_cover_image_public_bucket_hash
|
||||
.as_deref()
|
||||
.map(|hash| {
|
||||
MediaFileBucketPath::from_object_hash(
|
||||
hash,
|
||||
weight.maybe_avatar_public_bucket_prefix.as_deref(),
|
||||
weight.maybe_avatar_public_bucket_extension.as_deref())
|
||||
weight.maybe_cover_image_public_bucket_prefix.as_deref(),
|
||||
weight.maybe_cover_image_public_bucket_extension.as_deref())
|
||||
.get_full_object_path_str()
|
||||
.to_string()
|
||||
});
|
||||
@@ -176,7 +176,7 @@ pub async fn list_weights_by_user_handler(
|
||||
&weight.creator_display_name,
|
||||
&weight.creator_email_gravatar_hash,
|
||||
),
|
||||
maybe_avatar_public_bucket_path: maybe_avatar,
|
||||
maybe_cover_image_public_bucket_path: maybe_cover_image,
|
||||
description_markdown: weight.description_markdown,
|
||||
description_rendered_html: weight.description_rendered_html,
|
||||
file_size_bytes: weight.file_size_bytes,
|
||||
|
||||
@@ -3,7 +3,5 @@ pub mod get_weight;
|
||||
pub mod list_available_weights;
|
||||
pub mod list_featured_weights;
|
||||
pub mod list_weights_by_user;
|
||||
pub mod set_model_weight_avatar;
|
||||
pub mod update_weight;
|
||||
// pub mod create_weight; this is a private api call internally
|
||||
// pub mod drain_multipart_weights_request;
|
||||
pub mod set_model_weight_cover_image;
|
||||
pub mod update_weight;
|
||||
+4
-4
@@ -13,7 +13,7 @@ use http_server_common::request::get_request_ip::get_request_ip;
|
||||
use http_server_common::response::response_success_helpers::simple_json_success;
|
||||
use http_server_common::response::serialize_as_json_error::serialize_as_json_error;
|
||||
use mysql_queries::queries::media_files::get_media_file::get_media_file;
|
||||
use mysql_queries::queries::model_weights::edit::set_model_weight_avatar::{set_model_weight_avatar, UpdateArgs};
|
||||
use mysql_queries::queries::model_weights::edit::set_model_weight_cover_image::{set_model_weight_cover_image, UpdateArgs};
|
||||
use mysql_queries::queries::model_weights::get_weight::get_weight_by_token;
|
||||
use tokens::tokens::media_files::MediaFileToken;
|
||||
use tokens::tokens::model_weights::ModelWeightToken;
|
||||
@@ -70,7 +70,7 @@ impl fmt::Display for SetModelWeightAvatarError {
|
||||
|
||||
// =============== Handler ===============
|
||||
|
||||
pub async fn set_model_weight_avatar_handler(
|
||||
pub async fn set_model_weight_cover_image_handler(
|
||||
http_request: HttpRequest,
|
||||
path: Path<SetModelWeightAvatarPathInfo>,
|
||||
request: web::Json<SetModelWeightAvatarRequest>,
|
||||
@@ -161,9 +161,9 @@ pub async fn set_model_weight_avatar_handler(
|
||||
// TODO(bt,2023-12-21): DB needs a column, or we need an ip audit log
|
||||
let _ip_address = get_request_ip(&http_request);
|
||||
|
||||
let query_result = set_model_weight_avatar(UpdateArgs {
|
||||
let query_result = set_model_weight_cover_image(UpdateArgs {
|
||||
model_weight_token: &path.token,
|
||||
maybe_avatar_media_file_token: maybe_set_media_file_token.as_ref(),
|
||||
maybe_cover_image_media_file_token: maybe_set_media_file_token.as_ref(),
|
||||
mysql_pool: &server_state.mysql_pool,
|
||||
}).await;
|
||||
|
||||
@@ -20,7 +20,6 @@ use utoipa::ToSchema;
|
||||
#[derive(Deserialize, ToSchema)]
|
||||
pub struct UpdateWeightRequest {
|
||||
pub title: Option<String>,
|
||||
pub thumbnail_token: Option<String>,
|
||||
pub description_markdown: Option<String>,
|
||||
pub description_rendered_html: Option<String>,
|
||||
pub weight_type: Option<String>,
|
||||
@@ -143,7 +142,6 @@ pub async fn update_weight_handler(
|
||||
weight_token: &ModelWeightToken::new(path.weight_token.clone()),
|
||||
mysql_pool: &server_state.mysql_pool,
|
||||
title: request.title.as_deref(),
|
||||
maybe_thumbnail_token: request.thumbnail_token.as_deref(),
|
||||
description_markdown: request.description_markdown.as_deref(),
|
||||
description_rendered_html: request.description_rendered_html.as_deref(),
|
||||
creator_set_visibility: request.visibility.as_ref(),
|
||||
|
||||
@@ -160,7 +160,7 @@ use crate::http_server::endpoints::weights::get_weight::get_weight_handler;
|
||||
use crate::http_server::endpoints::weights::list_available_weights::list_available_weights_handler;
|
||||
use crate::http_server::endpoints::weights::list_featured_weights::list_featured_weights_handler;
|
||||
use crate::http_server::endpoints::weights::list_weights_by_user::list_weights_by_user_handler;
|
||||
use crate::http_server::endpoints::weights::set_model_weight_avatar::set_model_weight_avatar_handler;
|
||||
use crate::http_server::endpoints::weights::set_model_weight_cover_image::set_model_weight_cover_image_handler;
|
||||
use crate::http_server::endpoints::weights::update_weight::update_weight_handler;
|
||||
|
||||
pub fn add_routes<T, B> (app: App<T>, server_environment: ServerEnvironment) -> App<T>
|
||||
@@ -1278,8 +1278,8 @@ fn add_weights_routes<T, B>(app: App<T>) -> App<T>
|
||||
.route(web::post().to(update_weight_handler))
|
||||
.route(web::delete().to(delete_weight_handler))
|
||||
)
|
||||
.service(web::resource("/weight/{token}/avatar")
|
||||
.route(web::post().to(set_model_weight_avatar_handler))
|
||||
.service(web::resource("/weight/{token}/cover_image")
|
||||
.route(web::post().to(set_model_weight_cover_image_handler))
|
||||
)
|
||||
.route("/by_user/{username}", web::get().to(list_weights_by_user_handler))
|
||||
.route("/list", web::get().to(list_available_weights_handler))
|
||||
|
||||
Reference in new issue
Block a user