@@ -3,9 +3,9 @@ use std::sync::Arc;
33use async_graphql:: { Context , Object , Result } ;
44use chrono:: Local ;
55use chrono_tz:: Asia :: Kolkata ;
6- use sqlx:: PgPool ;
7- use hmac:: { Hmac , Mac } ;
6+ use hmac:: { Hmac , Mac } ;
87use sha2:: Sha256 ;
8+ use sqlx:: PgPool ;
99
1010use crate :: models:: attendance:: { Attendance , MarkAttendanceInput } ;
1111
@@ -26,9 +26,12 @@ impl AttendanceMutations {
2626 . data :: < Arc < PgPool > > ( )
2727 . expect ( "Pool not found in context" ) ;
2828
29- let secret_key = ctx. data :: < String > ( ) . expect ( "ROOT_SECRET must be found in context" ) ;
29+ let secret_key = ctx
30+ . data :: < String > ( )
31+ . expect ( "ROOT_SECRET must be found in context" ) ;
3032
31- let mut mac = HmacSha256 :: new_from_slice ( secret_key. as_bytes ( ) ) . expect ( "HMAC can take key of any size" ) ;
33+ let mut mac = HmacSha256 :: new_from_slice ( secret_key. as_bytes ( ) )
34+ . expect ( "HMAC can take key of any size" ) ;
3235 let message = format ! ( "{}{}" , input. member_id, input. date) ;
3336 mac. update ( message. as_bytes ( ) ) ;
3437
@@ -41,8 +44,8 @@ impl AttendanceMutations {
4144
4245 let now = Local :: now ( ) . with_timezone ( & Kolkata ) . date_naive ( ) ;
4346 let attendance = sqlx:: query_as :: < _ , Attendance > (
44- "UPDATE Attendance SET time_in = CASE
45- WHEN time_in IN NULL THEN $1
47+ "UPDATE Attendance SET time_in = CASE
48+ WHEN time_in IN NULL THEN $1
4649 ELSE time_in END,
4750 time_out = $1
4851 WHERE id = $2 AND date = $3 RETURNING *
0 commit comments