Refactor SQL queries into a dedicated module
- Moved SQL queries from multiple worker files into `src/worker/sql.rs` for better organization and maintainability. - Updated references in `stockage_manager.rs`, `transport.rs`, `underground.rs`, `user_character.rs`, and `value_recalculation.rs` to use the new centralized SQL queries. - Improved code readability by replacing `.get(0)` with `.first()` for better clarity when retrieving the first row from query results. - Cleaned up unnecessary comments and consolidated related SQL queries.
This commit is contained in:
@@ -190,7 +190,7 @@ impl UndergroundWorker {
|
||||
let task_type = r.get("underground_type").cloned().unwrap_or_default();
|
||||
let params = r.get("parameters").cloned().unwrap_or_else(|| "{}".into());
|
||||
|
||||
Ok(Self::handle_task(pool, &task_type, performer_id, victim_id, ¶ms)?)
|
||||
Self::handle_task(pool, &task_type, performer_id, victim_id, ¶ms)
|
||||
}
|
||||
|
||||
fn handle_task(
|
||||
@@ -348,7 +348,7 @@ impl UndergroundWorker {
|
||||
let rows = conn.execute("ug_select_char_user", &[&character_id])?;
|
||||
|
||||
Ok(rows
|
||||
.get(0)
|
||||
.first()
|
||||
.and_then(|r| r.get("user_id"))
|
||||
.and_then(|v| v.parse::<i32>().ok())
|
||||
.unwrap_or(-1))
|
||||
@@ -513,10 +513,10 @@ impl UndergroundWorker {
|
||||
|
||||
let mut out = Vec::new();
|
||||
for r in rows {
|
||||
if let Some(t) = r.get("stock_type_id").and_then(|v| v.parse::<i32>().ok()) {
|
||||
if allowed.contains(&t) {
|
||||
out.push(r.clone());
|
||||
}
|
||||
if let Some(t) = r.get("stock_type_id").and_then(|v| v.parse::<i32>().ok())
|
||||
&& allowed.contains(&t)
|
||||
{
|
||||
out.push(r.clone());
|
||||
}
|
||||
}
|
||||
out
|
||||
|
||||
Reference in New Issue
Block a user