working perfectly well now
This commit is contained in:
@@ -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 })
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user