aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjvech <jmvalenciae@unal.edu.co>2024-07-03 21:27:08 -0500
committerjvech <jmvalenciae@unal.edu.co>2024-07-03 21:27:08 -0500
commit5c9abec6cb729365439a7f783d63dfc32eeb2955 (patch)
tree69796699563d09e3e2904e9b4430c7a0e68c67e4
parent4b14f87cc80e7cfb78480644281022296973bc66 (diff)
add: show null agents total as zero done
-rw-r--r--Cargo.lock2
-rw-r--r--src/database.rs4
2 files changed, 3 insertions, 3 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 0ccb97d..b63090e 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -193,7 +193,7 @@ checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f"
[[package]]
name = "debt"
-version = "0.2.2"
+version = "1.0.0"
dependencies = [
"chrono",
"clap",
diff --git a/src/database.rs b/src/database.rs
index da514ef..e49b5a2 100644
--- a/src/database.rs
+++ b/src/database.rs
@@ -132,7 +132,7 @@ impl Database {
let mut stmt = conn.prepare("
SELECT a.name, sum(r.amount)
FROM Registers r
- INNER JOIN Agents a
+ RIGHT JOIN Agents a
ON a.id = r.agent_id
GROUP BY a.name")?;
let mut agents = stmt.query([])?;
@@ -141,7 +141,7 @@ impl Database {
println!("+{:->20}+{:->11}+", "", "");
while let Some(row) = agents.next()? {
let name: String = row.get(0)?;
- let amount: i32 = row.get(1)?;
+ let amount: i32 = row.get(1).unwrap_or(0);
println!("|{:>20}| {:>10}|", name, amount);
}
println!("+{:->20}+{:->11}+", "", "");
Feel free to download, copy and edit any repo