working perfectly well now

This commit is contained in:
filipriec
2025-02-21 14:58:52 +01:00
parent 7771299c81
commit 03e41eda9d
8 changed files with 82 additions and 18 deletions

View File

@@ -1,5 +1,5 @@
// src/adresar/handlers/get_adresar_count.rs
use tonic::{Status};
use tonic::Status;
use sqlx::PgPool;
use crate::proto::multieko2::{CountResponse, Empty};
@@ -8,12 +8,16 @@ pub async fn get_adresar_count(
_request: Empty,
) -> Result<CountResponse, Status> {
let count: i64 = sqlx::query_scalar!(
"SELECT COUNT(*) as count FROM adresar"
r#"
SELECT COUNT(*) AS count
FROM adresar
WHERE deleted = FALSE
"#
)
.fetch_one(db_pool)
.await
.map_err(|e| Status::internal(e.to_string()))?
.unwrap_or(0); // Handle the case where the count is None
.unwrap_or(0);
Ok(CountResponse { count })
}