File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed
Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -214,6 +214,27 @@ impl StatusInfo {
214214 }
215215}
216216
217+ #[ ComplexObject ]
218+ impl StatusUpdateRecord {
219+ async fn on_break ( & self , ctx : & Context < ' _ > ) -> Result < bool > {
220+ let pool = ctx. data :: < Arc < PgPool > > ( ) . expect ( "Pool must be in context." ) ;
221+
222+ let is_on_break = sqlx:: query_scalar (
223+ "SELECT EXISTS (
224+ SELECT 1 from StatusBreaks
225+ WHERE year = (SELECT year FROM Member WHERE member_id = $1)
226+ AND $2 BETWEEN start_date AND end_date
227+ )" ,
228+ )
229+ . bind ( self . member_id )
230+ . bind ( self . date )
231+ . fetch_optional ( pool. as_ref ( ) )
232+ . await ?;
233+
234+ Ok ( is_on_break. unwrap_or ( false ) )
235+ }
236+ }
237+
217238#[ Object ]
218239impl AttendanceInfo {
219240 async fn records (
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ use chrono::NaiveDate;
33use sqlx:: FromRow ;
44
55#[ derive( SimpleObject , FromRow ) ]
6+ #[ graphql( complex) ]
67pub struct StatusUpdateRecord {
78 pub update_id : i32 ,
89 pub member_id : i32 ,
You can’t perform that action at this time.
0 commit comments