Skip to content

Add a query that returns their status update count #128

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/graphql/queries/member_queries.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use async_graphql::{ComplexObject, Context, Object, Result};
use sqlx::PgPool;
use std::sync::Arc;
use chrono::NaiveDate;


use crate::models::{
attendance::{AttendanceInfo, AttendanceSummaryInfo},
Expand Down Expand Up @@ -107,4 +109,22 @@ impl Member {
.await
.unwrap_or_default()
}

async fn status_update_count_by_date(&self,
ctx: &Context<'_>,
start_date:NaiveDate,
end_date:NaiveDate)
-> Result<i64> {

let pool = ctx.data::<Arc<PgPool>>().expect("Pool must be in context.");

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;")
.bind(self.member_id)
.bind(start_date)
.bind(end_date)
.fetch_one(pool.as_ref())
.await?;

Ok(result)
}
}