@@ -3,9 +3,9 @@ use std::sync::Arc;
3
3
use async_graphql:: { Context , Object , Result } ;
4
4
use chrono:: Local ;
5
5
use chrono_tz:: Asia :: Kolkata ;
6
- use sqlx:: PgPool ;
7
- use hmac:: { Hmac , Mac } ;
6
+ use hmac:: { Hmac , Mac } ;
8
7
use sha2:: Sha256 ;
8
+ use sqlx:: PgPool ;
9
9
10
10
use crate :: models:: attendance:: { Attendance , MarkAttendanceInput } ;
11
11
@@ -26,9 +26,12 @@ impl AttendanceMutations {
26
26
. data :: < Arc < PgPool > > ( )
27
27
. expect ( "Pool not found in context" ) ;
28
28
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" ) ;
30
32
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" ) ;
32
35
let message = format ! ( "{}{}" , input. member_id, input. date) ;
33
36
mac. update ( message. as_bytes ( ) ) ;
34
37
@@ -41,8 +44,8 @@ impl AttendanceMutations {
41
44
42
45
let now = Local :: now ( ) . with_timezone ( & Kolkata ) . date_naive ( ) ;
43
46
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
46
49
ELSE time_in END,
47
50
time_out = $1
48
51
WHERE id = $2 AND date = $3 RETURNING *
0 commit comments