fixed minor bugs + added loggin middleware
All checks were successful
Tests / Run Go Tests (push) Successful in 1m26s

This commit is contained in:
2026-01-18 00:07:54 +01:00
parent 502955d32f
commit 560c539b19
6 changed files with 28 additions and 12 deletions

View File

@@ -245,12 +245,13 @@ func (b *Booking) Update(nb Booking) {
func checkLastBooking(b Booking) bool {
var check_in_out int
stmt, err := DB.Prepare((`SELECT check_in_out FROM "anwesenheit" WHERE "card_uid" = $1 ORDER BY "timestamp" DESC LIMIT 1;`))
slog.Info("Checking with timestamp:", "timestamp", b.Timestamp.String())
stmt, err := DB.Prepare((`SELECT check_in_out FROM "anwesenheit" WHERE "card_uid" = $1 AND "timestamp"::DATE <= $2::DATE ORDER BY "timestamp" DESC LIMIT 1;`))
if err != nil {
log.Fatalf("Error preparing query: %v", err)
return false
}
err = stmt.QueryRow(b.CardUID).Scan(&check_in_out)
err = stmt.QueryRow(b.CardUID, b.Timestamp).Scan(&check_in_out)
if err == sql.ErrNoRows {
return true
}