Skip to content

Commit efc6c51

Browse files
committed
adding statusUpdateCountByDate query which take two dates as arguments and give their status update count between those dates
1 parent 3c3bcec commit efc6c51

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/graphql/queries/member_queries.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
use async_graphql::{ComplexObject, Context, Object, Result};
22
use sqlx::PgPool;
33
use std::sync::Arc;
4+
use chrono::NaiveDate;
5+
46

57
use crate::models::{
68
attendance::{AttendanceInfo, AttendanceSummaryInfo},
@@ -107,4 +109,22 @@ impl Member {
107109
.await
108110
.unwrap_or_default()
109111
}
112+
113+
async fn status_update_count_by_date(&self,
114+
ctx: &Context<'_>,
115+
start_date:NaiveDate,
116+
end_date:NaiveDate)
117+
-> Result<i64> {
118+
119+
let pool = ctx.data::<Arc<PgPool>>().expect("Pool must be in context.");
120+
121+
let result : i64 = sqlx::query_scalar("SELECT count(*) as updatecount from statusupdatehistory where is_updated='t' and member_id=$1 and date between $2 and $3;")
122+
.bind(self.member_id)
123+
.bind(start_date)
124+
.bind(end_date)
125+
.fetch_one(pool.as_ref())
126+
.await?;
127+
128+
Ok(result)
129+
}
110130
}

0 commit comments

Comments
 (0)