mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-10 03:51:25 +00:00
add style_name (from prompt) to media file APIs
This commit is contained in:
1 parent
cd2e5d3696
commit
306d04d665
12 files changed
+144
-1
No files matched your search
@@ -23,6 +23,8 @@ use tokens::tokens::prompts::PromptToken;
|
||||
use tokens::tokens::users::UserToken;
|
||||
use tokens::traits::mysql_token_from_row::MySqlTokenFromRow;
|
||||
|
||||
use crate::payloads::prompt_args::prompt_inner_payload::PromptInnerPayload;
|
||||
|
||||
#[derive(Serialize, Debug)]
|
||||
pub struct MediaFile {
|
||||
pub token: MediaFileToken,
|
||||
@@ -53,6 +55,7 @@ pub struct MediaFile {
|
||||
pub creator_set_visibility: Visibility,
|
||||
|
||||
pub maybe_prompt_token: Option<PromptToken>,
|
||||
pub maybe_prompt_args: Option<PromptInnerPayload>,
|
||||
|
||||
pub maybe_file_cover_image_public_bucket_hash: Option<String>,
|
||||
pub maybe_file_cover_image_public_bucket_prefix: Option<String>,
|
||||
@@ -125,6 +128,7 @@ pub struct MediaFileRaw {
|
||||
pub creator_set_visibility: Visibility,
|
||||
|
||||
pub maybe_prompt_token: Option<PromptToken>,
|
||||
pub maybe_other_prompt_args: Option<String>,
|
||||
|
||||
pub maybe_file_cover_image_public_bucket_hash: Option<String>,
|
||||
pub maybe_file_cover_image_public_bucket_prefix: Option<String>,
|
||||
@@ -217,6 +221,12 @@ pub async fn batch_get_media_files(
|
||||
maybe_creator_gravatar_hash: record.maybe_creator_gravatar_hash,
|
||||
creator_set_visibility: record.creator_set_visibility,
|
||||
maybe_prompt_token: record.maybe_prompt_token,
|
||||
maybe_prompt_args: record.maybe_other_prompt_args
|
||||
.as_deref()
|
||||
.map(|args| PromptInnerPayload::from_json(args))
|
||||
.transpose()
|
||||
.ok() // NB: Fail open
|
||||
.flatten(),
|
||||
maybe_file_cover_image_public_bucket_hash: record.maybe_file_cover_image_public_bucket_hash,
|
||||
maybe_file_cover_image_public_bucket_prefix: record.maybe_file_cover_image_public_bucket_prefix,
|
||||
maybe_file_cover_image_public_bucket_extension: record.maybe_file_cover_image_public_bucket_extension,
|
||||
@@ -313,6 +323,8 @@ LEFT OUTER JOIN users as model_weight_creator
|
||||
LEFT OUTER JOIN entity_stats
|
||||
ON entity_stats.entity_type = "media_file"
|
||||
AND entity_stats.entity_token = m.token
|
||||
LEFT OUTER JOIN prompts
|
||||
ON prompts.token = m.maybe_prompt_token
|
||||
"#)
|
||||
}
|
||||
|
||||
@@ -349,6 +361,7 @@ impl FromRow<'_, MySqlRow> for MediaFileRaw {
|
||||
creator_set_visibility: Visibility::try_from_mysql_row(row, "creator_set_visibility")?,
|
||||
|
||||
maybe_prompt_token: PromptToken::try_from_mysql_row_nullable(row, "maybe_prompt_token")?,
|
||||
maybe_other_prompt_args: row.try_get("maybe_other_prompt_args")?,
|
||||
|
||||
maybe_file_cover_image_public_bucket_hash: row.try_get("maybe_file_cover_image_public_bucket_hash")?,
|
||||
maybe_file_cover_image_public_bucket_prefix: row.try_get("maybe_file_cover_image_public_bucket_prefix")?,
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
use anyhow::anyhow;
|
||||
use chrono::{DateTime, Utc};
|
||||
use sqlx::MySqlPool;
|
||||
use enums::by_table::media_files::media_file_class::MediaFileClass;
|
||||
|
||||
use enums::by_table::media_files::media_file_class::MediaFileClass;
|
||||
use enums::by_table::media_files::media_file_subtype::MediaFileSubtype;
|
||||
use enums::by_table::media_files::media_file_type::MediaFileType;
|
||||
use enums::by_table::model_weights::weights_category::WeightsCategory;
|
||||
@@ -21,6 +21,8 @@ use tokens::tokens::model_weights::ModelWeightToken;
|
||||
use tokens::tokens::prompts::PromptToken;
|
||||
use tokens::tokens::users::UserToken;
|
||||
|
||||
use crate::payloads::prompt_args::prompt_inner_payload::PromptInnerPayload;
|
||||
|
||||
#[derive(Serialize, Debug)]
|
||||
pub struct MediaFile {
|
||||
pub token: MediaFileToken,
|
||||
@@ -54,6 +56,7 @@ pub struct MediaFile {
|
||||
pub creator_set_visibility: Visibility,
|
||||
|
||||
pub maybe_prompt_token: Option<PromptToken>,
|
||||
pub maybe_prompt_args: Option<PromptInnerPayload>,
|
||||
|
||||
pub maybe_file_cover_image_public_bucket_hash: Option<String>,
|
||||
pub maybe_file_cover_image_public_bucket_prefix: Option<String>,
|
||||
@@ -129,6 +132,7 @@ pub struct MediaFileRaw {
|
||||
pub creator_set_visibility: Visibility,
|
||||
|
||||
pub maybe_prompt_token: Option<PromptToken>,
|
||||
pub maybe_other_prompt_args: Option<String>,
|
||||
|
||||
pub maybe_file_cover_image_public_bucket_hash: Option<String>,
|
||||
pub maybe_file_cover_image_public_bucket_prefix: Option<String>,
|
||||
@@ -185,6 +189,13 @@ pub async fn get_media_file(
|
||||
}
|
||||
};
|
||||
|
||||
let maybe_prompt_args = record.maybe_other_prompt_args
|
||||
.as_deref()
|
||||
.map(|args| PromptInnerPayload::from_json(args))
|
||||
.transpose()
|
||||
.ok() // NB: Fail open
|
||||
.flatten();
|
||||
|
||||
Ok(Some(MediaFile {
|
||||
token: record.token,
|
||||
media_type: record.media_type,
|
||||
@@ -202,6 +213,7 @@ pub async fn get_media_file(
|
||||
maybe_creator_anonymous_visitor_token: record.maybe_creator_anonymous_visitor_token,
|
||||
creator_set_visibility: record.creator_set_visibility,
|
||||
maybe_prompt_token: record.maybe_prompt_token,
|
||||
maybe_prompt_args,
|
||||
maybe_file_cover_image_public_bucket_hash: record.maybe_file_cover_image_public_bucket_hash,
|
||||
maybe_file_cover_image_public_bucket_prefix: record.maybe_file_cover_image_public_bucket_prefix,
|
||||
maybe_file_cover_image_public_bucket_extension: record.maybe_file_cover_image_public_bucket_extension,
|
||||
@@ -258,6 +270,7 @@ SELECT
|
||||
m.maybe_duration_millis,
|
||||
|
||||
m.maybe_prompt_token as `maybe_prompt_token: tokens::tokens::prompts::PromptToken`,
|
||||
prompts.maybe_other_args as maybe_other_prompt_args,
|
||||
|
||||
media_file_cover_image.public_bucket_directory_hash as maybe_file_cover_image_public_bucket_hash,
|
||||
media_file_cover_image.maybe_public_bucket_prefix as maybe_file_cover_image_public_bucket_prefix,
|
||||
@@ -304,6 +317,8 @@ LEFT OUTER JOIN users as model_weight_creator
|
||||
LEFT OUTER JOIN entity_stats
|
||||
ON entity_stats.entity_type = "media_file"
|
||||
AND entity_stats.entity_token = m.token
|
||||
LEFT OUTER JOIN prompts
|
||||
ON prompts.token = m.maybe_prompt_token
|
||||
WHERE
|
||||
m.token = ?
|
||||
"#,
|
||||
@@ -344,6 +359,7 @@ SELECT
|
||||
m.maybe_duration_millis,
|
||||
|
||||
m.maybe_prompt_token as `maybe_prompt_token: tokens::tokens::prompts::PromptToken`,
|
||||
prompts.maybe_other_args as maybe_other_prompt_args,
|
||||
|
||||
media_file_cover_image.public_bucket_directory_hash as maybe_file_cover_image_public_bucket_hash,
|
||||
media_file_cover_image.maybe_public_bucket_prefix as maybe_file_cover_image_public_bucket_prefix,
|
||||
@@ -390,6 +406,8 @@ LEFT OUTER JOIN users as model_weight_creator
|
||||
LEFT OUTER JOIN entity_stats
|
||||
ON entity_stats.entity_type = "media_file"
|
||||
AND entity_stats.entity_token = m.token
|
||||
LEFT OUTER JOIN prompts
|
||||
ON prompts.token = m.maybe_prompt_token
|
||||
WHERE
|
||||
m.token = ?
|
||||
AND m.user_deleted_at IS NULL
|
||||
|
||||
@@ -13,6 +13,7 @@ use enums::traits::mysql_from_row::MySqlFromRow;
|
||||
use errors::AnyhowResult;
|
||||
use tokens::tokens::media_files::MediaFileToken;
|
||||
use tokens::tokens::users::UserToken;
|
||||
use crate::payloads::prompt_args::prompt_inner_payload::PromptInnerPayload;
|
||||
|
||||
pub struct MediaFileListPage {
|
||||
pub records: Vec<MediaFileListItem>,
|
||||
@@ -52,6 +53,7 @@ pub struct MediaFileListItem {
|
||||
|
||||
pub maybe_title: Option<String>,
|
||||
pub maybe_text_transcript: Option<String>,
|
||||
pub maybe_prompt_args: Option<PromptInnerPayload>,
|
||||
|
||||
pub creator_set_visibility: Visibility,
|
||||
|
||||
@@ -124,6 +126,12 @@ pub async fn list_media_files(args: ListMediaFilesArgs<'_>) -> AnyhowResult<Medi
|
||||
maybe_creator_gravatar_hash: record.maybe_creator_gravatar_hash,
|
||||
maybe_title: record.maybe_title,
|
||||
maybe_text_transcript: record.maybe_text_transcript,
|
||||
maybe_prompt_args: record.maybe_other_prompt_args
|
||||
.as_deref()
|
||||
.map(|args| PromptInnerPayload::from_json(args))
|
||||
.transpose()
|
||||
.ok() // NB: Fail open
|
||||
.flatten(),
|
||||
creator_set_visibility: record.creator_set_visibility,
|
||||
maybe_file_cover_image_public_bucket_hash: record.maybe_file_cover_image_public_bucket_hash,
|
||||
maybe_file_cover_image_public_bucket_prefix: record.maybe_file_cover_image_public_bucket_prefix,
|
||||
@@ -174,6 +182,7 @@ SELECT
|
||||
m.maybe_origin_model_token,
|
||||
|
||||
w.title as maybe_origin_model_title,
|
||||
prompts.maybe_other_args as maybe_other_prompt_args,
|
||||
|
||||
m.public_bucket_directory_hash,
|
||||
m.maybe_public_bucket_prefix,
|
||||
@@ -218,6 +227,8 @@ LEFT OUTER JOIN comments as c
|
||||
LEFT OUTER JOIN entity_stats
|
||||
ON entity_stats.entity_type = "media_file"
|
||||
AND entity_stats.entity_token = m.token
|
||||
LEFT OUTER JOIN prompts
|
||||
ON prompts.token = m.maybe_prompt_token
|
||||
"#
|
||||
);
|
||||
|
||||
@@ -342,6 +353,7 @@ struct MediaFileListItemInternal {
|
||||
|
||||
maybe_title: Option<String>,
|
||||
maybe_text_transcript: Option<String>,
|
||||
maybe_other_prompt_args: Option<String>,
|
||||
|
||||
created_at: DateTime<Utc>,
|
||||
updated_at: DateTime<Utc>,
|
||||
@@ -387,6 +399,7 @@ impl FromRow<'_, MySqlRow> for MediaFileListItemInternal {
|
||||
maybe_file_cover_image_public_bucket_extension: row.try_get("maybe_file_cover_image_public_bucket_extension")?,
|
||||
maybe_title: row.try_get("maybe_title")?,
|
||||
maybe_text_transcript: row.try_get("maybe_text_transcript")?,
|
||||
maybe_other_prompt_args: row.try_get("maybe_other_prompt_args")?,
|
||||
created_at: row.try_get("created_at")?,
|
||||
updated_at: row.try_get("updated_at")?,
|
||||
comment_count: row.try_get("comment_count")?,
|
||||
|
||||
+13
@@ -12,6 +12,7 @@ use enums::traits::mysql_from_row::MySqlFromRow;
|
||||
use errors::AnyhowResult;
|
||||
use tokens::tokens::batch_generations::BatchGenerationToken;
|
||||
use tokens::tokens::media_files::MediaFileToken;
|
||||
use crate::payloads::prompt_args::prompt_inner_payload::PromptInnerPayload;
|
||||
|
||||
pub struct MediaFileListPage {
|
||||
pub records: Vec<MediaFileListItem>,
|
||||
@@ -45,6 +46,7 @@ pub struct MediaFileListItem {
|
||||
|
||||
/// Text transcripts for TTS, etc.
|
||||
pub maybe_text_transcript: Option<String>,
|
||||
pub maybe_prompt_args: Option<PromptInnerPayload>,
|
||||
|
||||
pub maybe_ratings_positive_count: Option<u32>,
|
||||
pub maybe_ratings_negative_count: Option<u32>,
|
||||
@@ -112,6 +114,12 @@ pub async fn list_media_files_by_batch_token(args: ListMediaFileByBatchArgs<'_>)
|
||||
creator_set_visibility: record.creator_set_visibility,
|
||||
maybe_title: record.maybe_title,
|
||||
maybe_text_transcript: record.maybe_text_transcript,
|
||||
maybe_prompt_args: record.maybe_other_prompt_args
|
||||
.as_deref()
|
||||
.map(|args| PromptInnerPayload::from_json(args))
|
||||
.transpose()
|
||||
.ok() // NB: Fail open
|
||||
.flatten(),
|
||||
maybe_ratings_positive_count: record.maybe_ratings_positive_count,
|
||||
maybe_ratings_negative_count: record.maybe_ratings_negative_count,
|
||||
maybe_bookmark_count: record.maybe_bookmark_count,
|
||||
@@ -153,6 +161,7 @@ fn select_result_fields() -> String {
|
||||
|
||||
m.maybe_title,
|
||||
m.maybe_text_transcript,
|
||||
prompts.maybe_other_args as maybe_other_prompt_args,
|
||||
|
||||
entity_stats.ratings_positive_count as maybe_ratings_positive_count,
|
||||
entity_stats.ratings_negative_count as maybe_ratings_negative_count,
|
||||
@@ -194,6 +203,8 @@ LEFT OUTER JOIN model_weights as w
|
||||
LEFT OUTER JOIN entity_stats
|
||||
ON entity_stats.entity_type = "media_file"
|
||||
AND entity_stats.entity_token = m.token
|
||||
LEFT OUTER JOIN prompts
|
||||
ON prompts.token = m.maybe_prompt_token
|
||||
"#
|
||||
));
|
||||
|
||||
@@ -253,6 +264,7 @@ struct MediaFileListItemInternal {
|
||||
|
||||
/// Text transcripts for TTS, etc.
|
||||
maybe_text_transcript: Option<String>,
|
||||
maybe_other_prompt_args: Option<String>,
|
||||
|
||||
maybe_ratings_positive_count: Option<u32>,
|
||||
maybe_ratings_negative_count: Option<u32>,
|
||||
@@ -291,6 +303,7 @@ impl FromRow<'_, MySqlRow> for MediaFileListItemInternal {
|
||||
creator_set_visibility: Visibility::try_from_mysql_row(row, "creator_set_visibility")?,
|
||||
maybe_title: row.try_get("maybe_title")?,
|
||||
maybe_text_transcript: row.try_get("maybe_text_transcript")?,
|
||||
maybe_other_prompt_args: row.try_get("maybe_other_prompt_args")?,
|
||||
maybe_ratings_positive_count: row.try_get("maybe_ratings_positive_count")?,
|
||||
maybe_ratings_negative_count: row.try_get("maybe_ratings_negative_count")?,
|
||||
maybe_bookmark_count: row.try_get("maybe_bookmark_count")?,
|
||||
|
||||
@@ -10,6 +10,7 @@ use enums::traits::mysql_from_row::MySqlFromRow;
|
||||
use errors::AnyhowResult;
|
||||
use tokens::tokens::media_files::MediaFileToken;
|
||||
use tokens::tokens::users::UserToken;
|
||||
use crate::payloads::prompt_args::prompt_inner_payload::PromptInnerPayload;
|
||||
|
||||
#[derive(Serialize)]
|
||||
pub struct MediaFilesByTokensRecord {
|
||||
@@ -43,6 +44,7 @@ pub struct MediaFilesByTokensRecord {
|
||||
|
||||
/// Text transcripts for TTS, etc.
|
||||
pub maybe_text_transcript: Option<String>,
|
||||
pub maybe_prompt_args: Option<PromptInnerPayload>,
|
||||
|
||||
pub maybe_file_cover_image_public_bucket_hash: Option<String>,
|
||||
pub maybe_file_cover_image_public_bucket_prefix: Option<String>,
|
||||
@@ -98,6 +100,7 @@ async fn get_raw_media_files_by_tokens(
|
||||
|
||||
m.maybe_title,
|
||||
m.maybe_text_transcript,
|
||||
prompts.maybe_other_args as maybe_other_prompt_args,
|
||||
|
||||
entity_stats.ratings_positive_count as maybe_ratings_positive_count,
|
||||
entity_stats.ratings_negative_count as maybe_ratings_negative_count,
|
||||
@@ -114,6 +117,8 @@ async fn get_raw_media_files_by_tokens(
|
||||
LEFT OUTER JOIN entity_stats
|
||||
ON entity_stats.entity_type = "media_file"
|
||||
AND entity_stats.entity_token = m.token
|
||||
LEFT OUTER JOIN prompts
|
||||
ON prompts.token = m.maybe_prompt_token
|
||||
WHERE
|
||||
m.creator_set_visibility = "public"
|
||||
AND m.token IN (
|
||||
@@ -145,6 +150,7 @@ async fn get_raw_media_files_by_tokens(
|
||||
|
||||
m.maybe_title,
|
||||
m.maybe_text_transcript,
|
||||
prompts.maybe_other_args as maybe_other_prompt_args,
|
||||
|
||||
entity_stats.ratings_positive_count as maybe_ratings_positive_count,
|
||||
entity_stats.ratings_negative_count as maybe_ratings_negative_count,
|
||||
@@ -167,6 +173,8 @@ async fn get_raw_media_files_by_tokens(
|
||||
AND entity_stats.entity_token = m.token
|
||||
LEFT OUTER JOIN media_files as media_file_cover_image
|
||||
ON media_file_cover_image.token = m.maybe_cover_image_media_file_token
|
||||
LEFT OUTER JOIN prompts
|
||||
ON prompts.token = m.maybe_prompt_token
|
||||
WHERE
|
||||
m.creator_set_visibility = "public"
|
||||
AND m.user_deleted_at IS NULL
|
||||
@@ -228,6 +236,13 @@ fn map_to_media_files(dataset:Vec<RawMediaFileJoinUser>) -> Vec<MediaFilesByToke
|
||||
maybe_title: media_file.maybe_title,
|
||||
maybe_text_transcript: media_file.maybe_text_transcript,
|
||||
|
||||
maybe_prompt_args: media_file.maybe_other_prompt_args
|
||||
.as_deref()
|
||||
.map(|args| PromptInnerPayload::from_json(args))
|
||||
.transpose()
|
||||
.ok() // NB: Fail open
|
||||
.flatten(),
|
||||
|
||||
maybe_file_cover_image_public_bucket_hash: media_file.maybe_file_cover_image_public_bucket_hash,
|
||||
maybe_file_cover_image_public_bucket_prefix: media_file.maybe_file_cover_image_public_bucket_prefix,
|
||||
maybe_file_cover_image_public_bucket_extension: media_file.maybe_file_cover_image_public_bucket_extension,
|
||||
@@ -269,6 +284,7 @@ fn map_to_media_files(dataset:Vec<RawMediaFileJoinUser>) -> Vec<MediaFilesByToke
|
||||
|
||||
pub maybe_title: Option<String>,
|
||||
pub maybe_text_transcript: Option<String>,
|
||||
pub maybe_other_prompt_args: Option<String>,
|
||||
|
||||
pub maybe_file_cover_image_public_bucket_hash: Option<String>,
|
||||
pub maybe_file_cover_image_public_bucket_prefix: Option<String>,
|
||||
@@ -313,6 +329,7 @@ impl FromRow<'_, MySqlRow> for RawMediaFileJoinUser {
|
||||
maybe_bookmark_count: row.try_get("maybe_bookmark_count")?,
|
||||
maybe_title: row.try_get("maybe_title")?,
|
||||
maybe_text_transcript: row.try_get("maybe_text_transcript")?,
|
||||
maybe_other_prompt_args: row.try_get("maybe_other_prompt_args")?,
|
||||
maybe_file_cover_image_public_bucket_hash: row.try_get("maybe_file_cover_image_public_bucket_hash")?,
|
||||
maybe_file_cover_image_public_bucket_prefix: row.try_get("maybe_file_cover_image_public_bucket_prefix")?,
|
||||
maybe_file_cover_image_public_bucket_extension: row.try_get("maybe_file_cover_image_public_bucket_extension")?,
|
||||
|
||||
@@ -15,6 +15,8 @@ use enums::traits::mysql_from_row::MySqlFromRow;
|
||||
use errors::AnyhowResult;
|
||||
use tokens::tokens::media_files::MediaFileToken;
|
||||
|
||||
use crate::payloads::prompt_args::prompt_inner_payload::PromptInnerPayload;
|
||||
|
||||
pub struct MediaFileListPage {
|
||||
pub records: Vec<MediaFileListItem>,
|
||||
|
||||
@@ -53,6 +55,7 @@ pub struct MediaFileListItem {
|
||||
|
||||
/// Text transcripts for TTS, etc.
|
||||
pub maybe_text_transcript: Option<String>,
|
||||
pub maybe_prompt_args: Option<PromptInnerPayload>,
|
||||
|
||||
pub maybe_ratings_positive_count: Option<u32>,
|
||||
pub maybe_ratings_negative_count: Option<u32>,
|
||||
@@ -133,6 +136,12 @@ pub async fn list_media_files_for_user(args: ListMediaFileForUserArgs<'_>) -> An
|
||||
maybe_file_cover_image_public_bucket_extension: record.maybe_file_cover_image_public_bucket_extension,
|
||||
maybe_title: record.maybe_title,
|
||||
maybe_text_transcript: record.maybe_text_transcript,
|
||||
maybe_prompt_args: record.maybe_other_prompt_args
|
||||
.as_deref()
|
||||
.map(|args| PromptInnerPayload::from_json(args))
|
||||
.transpose()
|
||||
.ok() // NB: Fail open
|
||||
.flatten(),
|
||||
maybe_ratings_positive_count: record.maybe_ratings_positive_count,
|
||||
maybe_ratings_negative_count: record.maybe_ratings_negative_count,
|
||||
maybe_bookmark_count: record.maybe_bookmark_count,
|
||||
@@ -179,6 +188,7 @@ fn select_result_fields() -> String {
|
||||
|
||||
m.maybe_title,
|
||||
m.maybe_text_transcript,
|
||||
prompts.maybe_other_args as maybe_other_prompt_args,
|
||||
|
||||
entity_stats.ratings_positive_count as maybe_ratings_positive_count,
|
||||
entity_stats.ratings_negative_count as maybe_ratings_negative_count,
|
||||
@@ -225,6 +235,8 @@ LEFT OUTER JOIN media_files as media_file_cover_image
|
||||
LEFT OUTER JOIN entity_stats
|
||||
ON entity_stats.entity_type = "media_file"
|
||||
AND entity_stats.entity_token = m.token
|
||||
LEFT OUTER JOIN prompts
|
||||
ON prompts.token = m.maybe_prompt_token
|
||||
"#
|
||||
));
|
||||
|
||||
@@ -312,6 +324,7 @@ struct MediaFileListItemInternal {
|
||||
|
||||
// NB: The title won't be populated for `tts_models` records or non-`model_weights` records.
|
||||
maybe_origin_model_title: Option<String>,
|
||||
maybe_other_prompt_args: Option<String>,
|
||||
|
||||
media_type: MediaFileType,
|
||||
media_class: MediaFileClass,
|
||||
@@ -361,6 +374,7 @@ impl FromRow<'_, MySqlRow> for MediaFileListItemInternal {
|
||||
maybe_origin_model_type: MediaFileOriginModelType::try_from_mysql_row_nullable(row, "maybe_origin_model_type")?,
|
||||
maybe_origin_model_token: row.try_get("maybe_origin_model_token")?,
|
||||
maybe_origin_model_title: row.try_get("maybe_origin_model_title")?,
|
||||
maybe_other_prompt_args: row.try_get("maybe_other_prompt_args")?,
|
||||
media_type: MediaFileType::try_from_mysql_row(row, "media_type")?,
|
||||
media_class: MediaFileClass::try_from_mysql_row(row, "media_class")?,
|
||||
public_bucket_directory_hash: row.try_get("public_bucket_directory_hash")?,
|
||||
|
||||
+9
@@ -18,6 +18,7 @@ use enums::by_table::media_files::media_file_type::MediaFileType;
|
||||
use enums::by_table::model_weights::weights_category::WeightsCategory;
|
||||
use enums::by_table::model_weights::weights_types::WeightsType;
|
||||
use enums::common::visibility::Visibility;
|
||||
use enums::no_table::style_transfer::style_transfer_name::StyleTransferName;
|
||||
use mysql_queries::queries::media_files::batch_get_media_files::batch_get_media_files;
|
||||
use mysql_queries::queries::media_files::get_media_file::get_media_file;
|
||||
use mysql_queries::queries::tts::tts_results::query_tts_result::select_tts_result_by_token;
|
||||
@@ -105,6 +106,10 @@ pub struct BatchMediaFileInfo {
|
||||
/// Text transcripts for TTS, etc.
|
||||
pub maybe_text_transcript: Option<String>,
|
||||
|
||||
/// For Comfy / Video Style Transfer jobs, this might include
|
||||
/// the name of the selected style.
|
||||
pub maybe_style_name: Option<StyleTransferName>,
|
||||
|
||||
/// The foreign key to the prompt used to generate the media, if applicable.
|
||||
pub maybe_prompt_token: Option<PromptToken>,
|
||||
|
||||
@@ -296,6 +301,10 @@ pub async fn batch_get_media_files_handler(
|
||||
),
|
||||
maybe_title: result.maybe_title,
|
||||
maybe_text_transcript: result.maybe_text_transcript,
|
||||
maybe_style_name: result.maybe_prompt_args
|
||||
.as_ref()
|
||||
.and_then(|args| args.style_name.as_ref())
|
||||
.and_then(|style| style.to_style_name()),
|
||||
maybe_model_weight_info: match result.maybe_model_weights_token {
|
||||
None => None,
|
||||
Some(weight_token) => Some(BatchGetMediaFilesModelInfo {
|
||||
|
||||
+10
@@ -16,6 +16,7 @@ use enums::by_table::media_files::media_file_type::MediaFileType;
|
||||
use enums::by_table::model_weights::weights_category::WeightsCategory;
|
||||
use enums::by_table::model_weights::weights_types::WeightsType;
|
||||
use enums::common::visibility::Visibility;
|
||||
use enums::no_table::style_transfer::style_transfer_name::StyleTransferName;
|
||||
use mysql_queries::queries::media_files::get_media_file::get_media_file;
|
||||
use mysql_queries::queries::tts::tts_results::query_tts_result::select_tts_result_by_token;
|
||||
use tokens::tokens::batch_generations::BatchGenerationToken;
|
||||
@@ -91,6 +92,10 @@ pub struct MediaFileInfo {
|
||||
/// Text transcripts for TTS, etc.
|
||||
pub maybe_text_transcript: Option<String>,
|
||||
|
||||
/// For Comfy / Video Style Transfer jobs, this might include
|
||||
/// the name of the selected style.
|
||||
pub maybe_style_name: Option<StyleTransferName>,
|
||||
|
||||
/// The foreign key to the prompt used to generate the media, if applicable.
|
||||
pub maybe_prompt_token: Option<PromptToken>,
|
||||
|
||||
@@ -312,6 +317,10 @@ async fn modern_media_file_lookup(
|
||||
),
|
||||
maybe_title: result.maybe_title,
|
||||
maybe_text_transcript: result.maybe_text_transcript,
|
||||
maybe_style_name: result.maybe_prompt_args
|
||||
.as_ref()
|
||||
.and_then(|args| args.style_name.as_ref())
|
||||
.and_then(|style| style.to_style_name()),
|
||||
maybe_model_weight_info: match result.maybe_model_weights_token {
|
||||
None => None,
|
||||
Some(weight_token) => Some(GetMediaFileModelInfo {
|
||||
@@ -419,6 +428,7 @@ async fn emulate_media_file_with_legacy_tts_result_lookup(
|
||||
result.maybe_creator_gravatar_hash,
|
||||
),
|
||||
maybe_prompt_token: None,
|
||||
maybe_style_name: None,
|
||||
creator_set_visibility: result.creator_set_visibility,
|
||||
maybe_title: None,
|
||||
maybe_text_transcript: Some(result.raw_inference_text),
|
||||
|
||||
+9
@@ -13,6 +13,7 @@ use enums::by_table::media_files::media_file_origin_category::MediaFileOriginCat
|
||||
use enums::by_table::media_files::media_file_origin_model_type::MediaFileOriginModelType;
|
||||
use enums::by_table::media_files::media_file_origin_product_category::MediaFileOriginProductCategory;
|
||||
use enums::by_table::media_files::media_file_type::MediaFileType;
|
||||
use enums::no_table::style_transfer::style_transfer_name::StyleTransferName;
|
||||
use mysql_queries::queries::media_files::list::list_media_files_by_tokens::list_media_files_by_tokens;
|
||||
use tokens::tokens::media_files::MediaFileToken;
|
||||
use users_component::common_responses::user_details_lite::UserDetailsLight;
|
||||
@@ -67,6 +68,10 @@ pub struct MediaFile {
|
||||
/// Text transcripts for TTS, etc.
|
||||
pub maybe_text_transcript: Option<String>,
|
||||
|
||||
/// For Comfy / Video Style Transfer jobs, this might include
|
||||
/// the name of the selected style.
|
||||
pub maybe_style_name: Option<StyleTransferName>,
|
||||
|
||||
/// Statistics about the media file
|
||||
pub stats: SimpleEntityStats,
|
||||
|
||||
@@ -190,6 +195,10 @@ pub async fn list_featured_media_files_handler(
|
||||
),
|
||||
maybe_title: m.maybe_title,
|
||||
maybe_text_transcript: m.maybe_text_transcript,
|
||||
maybe_style_name: m.maybe_prompt_args
|
||||
.as_ref()
|
||||
.and_then(|args| args.style_name.as_ref())
|
||||
.and_then(|style| style.to_style_name()),
|
||||
stats: SimpleEntityStats {
|
||||
positive_rating_count: m.maybe_ratings_positive_count.unwrap_or(0),
|
||||
bookmark_count: m.maybe_bookmark_count.unwrap_or(0),
|
||||
|
||||
+9
@@ -15,6 +15,7 @@ use enums::by_table::media_files::media_file_origin_product_category::MediaFileO
|
||||
use enums::by_table::media_files::media_file_type::MediaFileType;
|
||||
use enums::common::view_as::ViewAs;
|
||||
use enums::common::visibility::Visibility;
|
||||
use enums::no_table::style_transfer::style_transfer_name::StyleTransferName;
|
||||
use mysql_queries::queries::media_files::list::list_media_files_by_batch_token::{list_media_files_by_batch_token, ListMediaFileByBatchArgs};
|
||||
use mysql_queries::queries::media_files::list::list_media_files_for_user::{list_media_files_for_user, ListMediaFileForUserArgs};
|
||||
use tokens::tokens::batch_generations::BatchGenerationToken;
|
||||
@@ -85,6 +86,10 @@ pub struct MediaFilesByBatchListItem {
|
||||
/// Text transcripts for TTS, etc.
|
||||
pub maybe_text_transcript: Option<String>,
|
||||
|
||||
/// For Comfy / Video Style Transfer jobs, this might include
|
||||
/// the name of the selected style.
|
||||
pub maybe_style_name: Option<StyleTransferName>,
|
||||
|
||||
/// Statistics about the media file
|
||||
pub stats: SimpleEntityStats,
|
||||
|
||||
@@ -223,6 +228,10 @@ pub async fn list_media_files_by_batch_token_handler(
|
||||
creator_set_visibility: record.creator_set_visibility,
|
||||
maybe_title: record.maybe_title,
|
||||
maybe_text_transcript: record.maybe_text_transcript,
|
||||
maybe_style_name: record.maybe_prompt_args
|
||||
.as_ref()
|
||||
.and_then(|args| args.style_name.as_ref())
|
||||
.and_then(|style| style.to_style_name()),
|
||||
stats: SimpleEntityStats {
|
||||
positive_rating_count: record.maybe_ratings_positive_count.unwrap_or(0),
|
||||
bookmark_count: record.maybe_bookmark_count.unwrap_or(0),
|
||||
|
||||
+9
@@ -17,6 +17,7 @@ use enums::by_table::media_files::media_file_origin_product_category::MediaFileO
|
||||
use enums::by_table::media_files::media_file_type::MediaFileType;
|
||||
use enums::common::view_as::ViewAs;
|
||||
use enums::common::visibility::Visibility;
|
||||
use enums::no_table::style_transfer::style_transfer_name::StyleTransferName;
|
||||
use mysql_queries::queries::media_files::list::list_media_files_for_user::{list_media_files_for_user, ListMediaFileForUserArgs};
|
||||
use tokens::tokens::media_files::MediaFileToken;
|
||||
|
||||
@@ -95,6 +96,10 @@ pub struct MediaFileForUserListItem {
|
||||
/// Text transcripts for TTS, etc.
|
||||
pub maybe_text_transcript: Option<String>,
|
||||
|
||||
/// For Comfy / Video Style Transfer jobs, this might include
|
||||
/// the name of the selected style.
|
||||
pub maybe_style_name: Option<StyleTransferName>,
|
||||
|
||||
/// Statistics about the media file
|
||||
pub stats: SimpleEntityStats,
|
||||
|
||||
@@ -263,6 +268,10 @@ pub async fn list_media_files_for_user_handler(
|
||||
creator_set_visibility: record.creator_set_visibility,
|
||||
maybe_title: record.maybe_title,
|
||||
maybe_text_transcript: record.maybe_text_transcript,
|
||||
maybe_style_name: record.maybe_prompt_args
|
||||
.as_ref()
|
||||
.and_then(|args| args.style_name.as_ref())
|
||||
.and_then(|style| style.to_style_name()),
|
||||
stats: SimpleEntityStats {
|
||||
positive_rating_count: record.maybe_ratings_positive_count.unwrap_or(0),
|
||||
bookmark_count: record.maybe_bookmark_count.unwrap_or(0),
|
||||
|
||||
+9
@@ -15,6 +15,7 @@ use enums::by_table::media_files::media_file_origin_product_category::MediaFileO
|
||||
use enums::by_table::media_files::media_file_type::MediaFileType;
|
||||
use enums::common::view_as::ViewAs;
|
||||
use enums::common::visibility::Visibility;
|
||||
use enums::no_table::style_transfer::style_transfer_name::StyleTransferName;
|
||||
use mysql_queries::queries::media_files::list::list_media_files::{list_media_files, ListMediaFilesArgs};
|
||||
use tokens::tokens::media_files::MediaFileToken;
|
||||
use users_component::common_responses::user_details_lite::UserDetailsLight;
|
||||
@@ -86,6 +87,10 @@ pub struct MediaFileListItem {
|
||||
/// Text transcripts for TTS, etc.
|
||||
pub maybe_text_transcript: Option<String>,
|
||||
|
||||
/// For Comfy / Video Style Transfer jobs, this might include
|
||||
/// the name of the selected style.
|
||||
pub maybe_style_name: Option<StyleTransferName>,
|
||||
|
||||
pub created_at: DateTime<Utc>,
|
||||
pub updated_at: DateTime<Utc>,
|
||||
}
|
||||
@@ -264,6 +269,10 @@ pub async fn list_media_files_handler(
|
||||
creator_set_visibility: record.creator_set_visibility,
|
||||
maybe_title: record.maybe_title,
|
||||
maybe_text_transcript: record.maybe_text_transcript,
|
||||
maybe_style_name: record.maybe_prompt_args
|
||||
.as_ref()
|
||||
.and_then(|args| args.style_name.as_ref())
|
||||
.and_then(|style| style.to_style_name()),
|
||||
created_at: record.created_at,
|
||||
updated_at: record.updated_at,
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user