From c8668c59ebeae8159ada403065489a1fd0cecb1a Mon Sep 17 00:00:00 2001 From: "Torsten Schulz (local)" Date: Fri, 23 Jan 2026 10:48:15 +0100 Subject: [PATCH] Refactor relationship type retrieval in character workers: Simplify the extraction of relationship types in CharacterCreationWorker, EventsWorker, and UserCharacterWorker by streamlining the use of `and_then` for better readability and maintainability. --- src/worker/character_creation.rs | 4 +--- src/worker/events.rs | 3 +-- src/worker/user_character.rs | 4 +--- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/worker/character_creation.rs b/src/worker/character_creation.rs index 3214e37..306a9d6 100644 --- a/src/worker/character_creation.rs +++ b/src/worker/character_creation.rs @@ -3,7 +3,6 @@ use crate::message_broker::MessageBroker; use rand::distributions::{Distribution, Uniform}; use rand::rngs::StdRng; use rand::{thread_rng, Rng, SeedableRng}; -use serde_json::json; use std::collections::{HashMap, HashSet}; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::Arc; @@ -437,8 +436,7 @@ impl CharacterCreationWorker { .and_then(|v| v.parse::().ok()); let relationship_type_tr = row .get("relationship_type_tr") - .and_then(|v| v.as_str()) - .map(|s| s.to_string()); + .and_then(|v| v.as_str().map(|s| s.to_string())); // Logging: Relationship wurde gelöscht eprintln!( diff --git a/src/worker/events.rs b/src/worker/events.rs index 6af6402..7ee18b7 100644 --- a/src/worker/events.rs +++ b/src/worker/events.rs @@ -1797,8 +1797,7 @@ impl EventsWorker { .and_then(|v| v.parse::().ok()); let relationship_type_tr = row .get("relationship_type_tr") - .and_then(|v| v.as_str()) - .map(|s| s.to_string()); + .and_then(|v| v.as_str().map(|s| s.to_string())); // Logging: Relationship wurde gelöscht eprintln!( diff --git a/src/worker/user_character.rs b/src/worker/user_character.rs index 728862a..c6d28fb 100644 --- a/src/worker/user_character.rs +++ b/src/worker/user_character.rs @@ -3,7 +3,6 @@ use crate::message_broker::MessageBroker; use rand::distributions::{Distribution, Uniform}; use rand::rngs::StdRng; use rand::SeedableRng; -use serde_json::json; use std::sync::atomic::Ordering; use std::sync::Arc; use std::time::{Duration, Instant}; @@ -601,8 +600,7 @@ impl UserCharacterWorker { .and_then(|v| v.parse::().ok()); let relationship_type_tr = row .get("relationship_type_tr") - .and_then(|v| v.as_str()) - .map(|s| s.to_string()); + .and_then(|v| v.as_str().map(|s| s.to_string())); // Logging: Relationship wurde gelöscht eprintln!(