diff --git a/.sqlx/query-56f876c272472c3b2507c2b514e072289aa304ee5388a61da3b9f635d4368d45.json b/.sqlx/query-094eb099cde85835db0662c2700c6b82644b51bf9b3609391ed4d2945fe5e98f.json similarity index 86% rename from .sqlx/query-56f876c272472c3b2507c2b514e072289aa304ee5388a61da3b9f635d4368d45.json rename to .sqlx/query-094eb099cde85835db0662c2700c6b82644b51bf9b3609391ed4d2945fe5e98f.json index d83c8ff278..1963d96f9f 100644 --- a/.sqlx/query-56f876c272472c3b2507c2b514e072289aa304ee5388a61da3b9f635d4368d45.json +++ b/.sqlx/query-094eb099cde85835db0662c2700c6b82644b51bf9b3609391ed4d2945fe5e98f.json @@ -1,6 +1,6 @@ { "db_name": "MySQL", - "query": "\nSELECT\n pci.media_token as `media_token: tokens::tokens::media_files::MediaFileToken`,\n pci.context_semantic_type as `context_semantic_type: enums::by_table::prompt_context_items::prompt_context_semantic_type::PromptContextSemanticType`,\n\n m.public_bucket_directory_hash,\n m.maybe_public_bucket_prefix,\n m.maybe_public_bucket_extension\n\nFROM prompt_context_items pci\nLEFT OUTER JOIN media_files m\nON\n pci.media_token = m.token\nWHERE\n pci.prompt_token = ?\nORDER BY pci.id ASC\n ", + "query": "\nSELECT\n pci.media_token as `media_token: tokens::tokens::media_files::MediaFileToken`,\n pci.context_semantic_type as `context_semantic_type: enums::by_table::prompt_context_items::prompt_context_semantic_type::PromptContextSemanticType`,\n\n m.public_bucket_directory_hash,\n m.maybe_public_bucket_prefix,\n m.maybe_public_bucket_extension\n\nFROM prompt_context_items pci\nJOIN media_files m\nON\n pci.media_token = m.token\nWHERE\n pci.prompt_token = ?\nORDER BY pci.id ASC\n ", "describe": { "columns": [ { @@ -28,7 +28,7 @@ "name": "public_bucket_directory_hash", "type_info": { "type": "VarString", - "flags": "BINARY | NO_DEFAULT_VALUE", + "flags": "NOT_NULL | BINARY | NO_DEFAULT_VALUE", "char_set": 224, "max_size": 128 } @@ -60,10 +60,10 @@ "nullable": [ false, false, - true, + false, true, true ] }, - "hash": "56f876c272472c3b2507c2b514e072289aa304ee5388a61da3b9f635d4368d45" + "hash": "094eb099cde85835db0662c2700c6b82644b51bf9b3609391ed4d2945fe5e98f" } diff --git a/crates/schema/database/mysql_queries/src/queries/prompt_context_items/list_prompt_context_items.rs b/crates/schema/database/mysql_queries/src/queries/prompt_context_items/list_prompt_context_items.rs index 5103737f49..79f626ccc8 100644 --- a/crates/schema/database/mysql_queries/src/queries/prompt_context_items/list_prompt_context_items.rs +++ b/crates/schema/database/mysql_queries/src/queries/prompt_context_items/list_prompt_context_items.rs @@ -11,7 +11,7 @@ use tokens::tokens::prompts::PromptToken; pub struct PromptContextItem { pub media_token: MediaFileToken, pub context_semantic_type: PromptContextSemanticType, - pub maybe_public_bucket_directory_hash: Option, // NB: Shouldn't be nullable, but the join could loosen this + pub public_bucket_directory_hash: String, pub maybe_public_bucket_prefix: Option, pub maybe_public_bucket_extension: Option, } @@ -19,7 +19,7 @@ pub struct PromptContextItem { struct RawPromptContextItem { media_token: MediaFileToken, context_semantic_type: PromptContextSemanticType, - public_bucket_directory_hash: Option, + public_bucket_directory_hash: String, maybe_public_bucket_prefix: Option, maybe_public_bucket_extension: Option, } @@ -40,7 +40,7 @@ SELECT m.maybe_public_bucket_extension FROM prompt_context_items pci -LEFT OUTER JOIN media_files m +JOIN media_files m ON pci.media_token = m.token WHERE @@ -58,7 +58,7 @@ ORDER BY pci.id ASC PromptContextItem { media_token: item.media_token, context_semantic_type: item.context_semantic_type, - maybe_public_bucket_directory_hash: item.public_bucket_directory_hash, + public_bucket_directory_hash: item.public_bucket_directory_hash, maybe_public_bucket_prefix: item.maybe_public_bucket_prefix, maybe_public_bucket_extension: item.maybe_public_bucket_extension, } diff --git a/crates/service/web/storyteller_web/src/http_server/endpoints/prompts/get_prompt_handler.rs b/crates/service/web/storyteller_web/src/http_server/endpoints/prompts/get_prompt_handler.rs index 0da8b62d38..24c100fc8a 100644 --- a/crates/service/web/storyteller_web/src/http_server/endpoints/prompts/get_prompt_handler.rs +++ b/crates/service/web/storyteller_web/src/http_server/endpoints/prompts/get_prompt_handler.rs @@ -289,24 +289,20 @@ pub async fn get_prompt_handler( Vec::new() }); - let items = items.iter().filter_map(|item| { - if let Some(public_bucket_directory_hash) = &item.maybe_public_bucket_directory_hash { - let bucket_path = MediaFileBucketPath::from_object_hash( - public_bucket_directory_hash, - item.maybe_public_bucket_prefix.as_deref(), - item.maybe_public_bucket_extension.as_deref()); + let items = items.iter().map(|item| { + let bucket_path = MediaFileBucketPath::from_object_hash( + &item.public_bucket_directory_hash, + item.maybe_public_bucket_prefix.as_deref(), + item.maybe_public_bucket_extension.as_deref()); - Some(ImageContextItem { - media_token: item.media_token.clone(), - semantic: item.context_semantic_type, - media_links: MediaLinksBuilder::from_media_path_and_env( - media_domain, - server_state.server_environment, - &bucket_path, - ), - }) - } else { - None + ImageContextItem { + media_token: item.media_token.clone(), + semantic: item.context_semantic_type, + media_links: MediaLinksBuilder::from_media_path_and_env( + media_domain, + server_state.server_environment, + &bucket_path, + ), } }).collect::>();