1- use crate :: models:: attendance:: AttendanceRecord ;
1+ use crate :: models:: { attendance:: AttendanceRecord , status_update :: StatusUpdateRecord } ;
22use async_graphql:: { ComplexObject , Context , Object , Result } ;
33use chrono:: NaiveDate ;
44use sqlx:: PgPool ;
@@ -84,9 +84,9 @@ impl StatusInfo {
8484 ctx : & Context < ' _ > ,
8585 start_date : NaiveDate ,
8686 end_date : NaiveDate ,
87- ) -> Result < Vec < AttendanceRecord > > {
87+ ) -> Result < Vec < StatusUpdateRecord > > {
8888 let pool = ctx. data :: < Arc < PgPool > > ( ) ?;
89- let rows = sqlx:: query_as :: < _ , AttendanceRecord > (
89+ let rows = sqlx:: query_as :: < _ , StatusUpdateRecord > (
9090 "SELECT * FROM StatusUpdateHistory where date BETWEEN $1 and $2 AND member_id = $3" ,
9191 )
9292 . bind ( start_date)
@@ -98,6 +98,20 @@ impl StatusInfo {
9898 Ok ( rows)
9999 }
100100
101+ async fn on_date ( & self , ctx : & Context < ' _ > , date : NaiveDate ) -> Result < StatusUpdateRecord > {
102+ let pool = ctx. data :: < Arc < PgPool > > ( ) ?;
103+
104+ let rows = sqlx:: query_as :: < _ , StatusUpdateRecord > (
105+ "SELECT * FROM StatusUpdateHistory WHERE date = $1 AND member_id=$2" ,
106+ )
107+ . bind ( date)
108+ . bind ( self . member_id )
109+ . fetch_one ( pool. as_ref ( ) )
110+ . await ?;
111+
112+ Ok ( rows)
113+ }
114+
101115 async fn streak ( & self , ctx : & Context < ' _ > ) -> Result < StatusUpdateStreakRecord > {
102116 let pool = ctx. data :: < Arc < PgPool > > ( ) . expect ( "Pool must be in context." ) ;
103117
0 commit comments