mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-04 09:28:11 +00:00
get rid of optional
This commit is contained in:
1 parent
bf73437fd0
commit
f8ad10ea04
3 files changed
+21
-25
No files matched your search
+4
-4
@@ -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"
|
||||
}
|
||||
+4
-4
@@ -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<String>, // NB: Shouldn't be nullable, but the join could loosen this
|
||||
pub public_bucket_directory_hash: String,
|
||||
pub maybe_public_bucket_prefix: Option<String>,
|
||||
pub maybe_public_bucket_extension: Option<String>,
|
||||
}
|
||||
@@ -19,7 +19,7 @@ pub struct PromptContextItem {
|
||||
struct RawPromptContextItem {
|
||||
media_token: MediaFileToken,
|
||||
context_semantic_type: PromptContextSemanticType,
|
||||
public_bucket_directory_hash: Option<String>,
|
||||
public_bucket_directory_hash: String,
|
||||
maybe_public_bucket_prefix: Option<String>,
|
||||
maybe_public_bucket_extension: Option<String>,
|
||||
}
|
||||
@@ -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,
|
||||
}
|
||||
|
||||
+13
-17
@@ -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::<Vec<ImageContextItem>>();
|
||||
|
||||
|
||||
Reference in new issue
Block a user