Added edit_img command
+ Refactored image editing so it's all handled in the same way + Added pipeline concept for more advanced edits
This commit is contained in:
9 files changed
+477
-293
No files matched your search
+19
-18
@@ -58,13 +58,28 @@ impl MotivationConfig {
|
||||
|
||||
pub async fn generate_motivation(
|
||||
db: &Database,
|
||||
picox: &AlbumManager,
|
||||
border_color: &str,
|
||||
album_name: Option<String>,
|
||||
) -> Result<Motivation, Error> {
|
||||
let motivation = Self::get_motivation_config(db)?;
|
||||
let actions = RandomConfig::get_random(db, ACTION_RANDOM_GROUP)?.unwrap_or_default();
|
||||
let goals = RandomConfig::get_random(db, GOAL_RANDOM_GROUP)?.unwrap_or_default();
|
||||
|
||||
let action = actions.get_response(db)?.unwrap_or_default();
|
||||
let goal = goals.get_response(db)?.unwrap_or_default();
|
||||
|
||||
Ok(Motivation {
|
||||
action: action.to_string(),
|
||||
goal: goal.to_string(),
|
||||
border_color: border_color.to_string(),
|
||||
})
|
||||
}
|
||||
|
||||
pub async fn get_motivation_image(
|
||||
db: &Database,
|
||||
picox: &AlbumManager,
|
||||
album_name: Option<String>,
|
||||
) -> Result<Image, Error> {
|
||||
let mut images = Vec::new();
|
||||
let motivation = Self::get_motivation_config(db)?;
|
||||
|
||||
if let Some(album_name) = album_name {
|
||||
let query = AlbumQuery {
|
||||
@@ -92,26 +107,12 @@ impl MotivationConfig {
|
||||
|
||||
let image = images.choose(&mut rng()).ok_or(Error::NoAlbumFound)?;
|
||||
|
||||
let actions = RandomConfig::get_random(db, ACTION_RANDOM_GROUP)?.unwrap_or_default();
|
||||
let goals = RandomConfig::get_random(db, GOAL_RANDOM_GROUP)?.unwrap_or_default();
|
||||
|
||||
let action = actions.get_response(db)?.unwrap_or_default();
|
||||
let goal = goals.get_response(db)?.unwrap_or_default();
|
||||
|
||||
let image = picox.get_image_by_id(*image).await?;
|
||||
|
||||
Ok(Motivation {
|
||||
image,
|
||||
action: action.to_string(),
|
||||
goal: goal.to_string(),
|
||||
border_color: border_color.to_string(),
|
||||
})
|
||||
picox.get_image_by_id(*image).await
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize, Clone)]
|
||||
pub struct Motivation {
|
||||
pub image: Image,
|
||||
pub action: String,
|
||||
pub goal: String,
|
||||
pub border_color: String,
|
||||
|
||||
Reference in new issue
Block a user