mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-04 01:18:34 +00:00
query fixup
This commit is contained in:
1 parent
7131052d49
commit
55b1b08310
4 files changed
+6
-17
No files matched your search
+1
-2
@@ -1,4 +1,3 @@
|
||||
use errors::AnyhowResult;
|
||||
use sqlx::pool::PoolConnection;
|
||||
use sqlx::{FromRow, MySql, QueryBuilder};
|
||||
|
||||
@@ -20,7 +19,7 @@ pub struct CharacterPromptData {
|
||||
pub async fn batch_lookup_characters_by_token_for_prompting(
|
||||
tokens: &[CharacterToken],
|
||||
connection: &mut PoolConnection<MySql>,
|
||||
) -> AnyhowResult<Vec<CharacterPromptData>> {
|
||||
) -> Result<Vec<CharacterPromptData>, sqlx::Error> {
|
||||
if tokens.is_empty() {
|
||||
return Ok(Vec::new());
|
||||
}
|
||||
|
||||
+2
-4
@@ -1,4 +1,3 @@
|
||||
use anyhow::anyhow;
|
||||
use log::info;
|
||||
use sqlx::{Executor, MySql};
|
||||
use std::marker::PhantomData;
|
||||
@@ -50,7 +49,7 @@ pub struct CreatePendingCharacterArgs<'e, 'c, E>
|
||||
/// once the async creation job completes.
|
||||
pub async fn create_pending_character<'e, 'c: 'e, E>(
|
||||
args: CreatePendingCharacterArgs<'e, 'c, E>,
|
||||
) -> anyhow::Result<CharacterToken>
|
||||
) -> Result<CharacterToken, sqlx::Error>
|
||||
where E: 'e + Executor<'c, Database = MySql>
|
||||
{
|
||||
let token = CharacterToken::generate();
|
||||
@@ -87,8 +86,7 @@ SET
|
||||
);
|
||||
|
||||
let result = query.execute(args.mysql_executor)
|
||||
.await
|
||||
.map_err(|err| anyhow!("Error inserting character: {:?}", err))?;
|
||||
.await?;
|
||||
|
||||
info!("Created pending character {} (record ID {})", token, result.last_insert_id());
|
||||
|
||||
|
||||
+2
-6
@@ -174,11 +174,7 @@ pub async fn create_character_handler(
|
||||
mysql_executor: &mut *transaction,
|
||||
phantom: PhantomData,
|
||||
})
|
||||
.await
|
||||
.map_err(|err| {
|
||||
error!("Error inserting character record: {:?}", err);
|
||||
AdvancedCommonWebError::from_anyhow_error(err)
|
||||
})?;
|
||||
.await?;
|
||||
|
||||
info!("Created pending character: {}", character_token);
|
||||
|
||||
@@ -198,7 +194,7 @@ pub async fn create_character_handler(
|
||||
.await
|
||||
.map_err(|err| {
|
||||
error!("Error inserting inference job: {:?}", err);
|
||||
AdvancedCommonWebError::from_anyhow_error(err.into())
|
||||
AdvancedCommonWebError::from_error(err)
|
||||
})?;
|
||||
|
||||
info!("Created inference job: {}", apriori_job_token);
|
||||
|
||||
+1
-5
@@ -616,11 +616,7 @@ async fn resolve_kinovi_character_ids(
|
||||
};
|
||||
|
||||
let characters = batch_lookup_characters_by_token_for_prompting(tokens, connection)
|
||||
.await
|
||||
.map_err(|err| {
|
||||
error!("Error looking up characters: {:?}", err);
|
||||
AdvancedCommonWebError::from_anyhow_error(err)
|
||||
})?;
|
||||
.await?;
|
||||
|
||||
if characters.len() != tokens.len() {
|
||||
warn!(
|
||||
|
||||
Reference in new issue
Block a user