Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Attendance not being logged #68

Merged
merged 1 commit into from
Feb 25, 2025
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