Skip to content
Merged
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
14 changes: 6 additions & 8 deletions src/graphql/mutations/attendance_mutations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,15 @@ impl AttendanceMutations {

let now = Local::now().with_timezone(&Kolkata).time();
let attendance = sqlx::query_as::<_, Attendance>(
"UPDATE Attendance SET time_in = CASE
WHEN time_in IS NULL THEN $1
ELSE time_in END,
time_out = $1,
is_present = TRUE
WHERE member_id = $2 AND date = $3 RETURNING *
",
"INSERT INTO Attendance (member_id, date, is_present, time_in, time_out)
VALUES ($1, $2, TRUE, $3, $3)
ON CONFLICT (member_id, date) DO UPDATE SET
time_out = $3
RETURNING *",
)
.bind(now)
.bind(input.member_id)
.bind(input.date)
.bind(now)
.fetch_one(pool.as_ref())
.await?;

Expand Down
Loading