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:
@@ -86,15 +86,7 @@ async fn append_ws_log(
|
||||
.map(|s| s.to_string());
|
||||
let target_user = json
|
||||
.get("user_id")
|
||||
.and_then(|v| {
|
||||
if let Some(s) = v.as_str() {
|
||||
Some(s.to_string())
|
||||
} else if let Some(n) = v.as_i64() {
|
||||
Some(n.to_string())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
});
|
||||
.and_then(|v| v.as_str().map(|s| s.to_string()).or_else(|| v.as_i64().map(|n| n.to_string())));
|
||||
(event, target_user)
|
||||
} else {
|
||||
(None, None)
|
||||
@@ -510,10 +502,8 @@ async fn handle_connection<S>(
|
||||
.and_then(|v| {
|
||||
if let Some(s) = v.as_str() {
|
||||
s.parse::<i64>().ok()
|
||||
} else if let Some(n) = v.as_i64() {
|
||||
Some(n)
|
||||
} else {
|
||||
None
|
||||
v.as_i64()
|
||||
}
|
||||
})
|
||||
.map(|v| v == numeric_uid)
|
||||
|
||||
Reference in New Issue
Block a user