adding more logging + working on displaying if a workday was submitted
Some checks failed
Tests / Run Go Tests (push) Failing after 1m55s
Some checks failed
Tests / Run Go Tests (push) Failing after 1m55s
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"log"
|
||||
"log/slog"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"time"
|
||||
@@ -87,6 +88,27 @@ func (b *Booking) Verify() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (b *Booking) IsSubmittedAndChecked() bool {
|
||||
qStr, err := DB.Prepare(`SELECT bestaetigt from wochen_report WHERE $1 = ANY(anwesenheiten);`)
|
||||
if err != nil {
|
||||
slog.Warn("Error when preparing SQL Statement", "error", err)
|
||||
return false
|
||||
}
|
||||
defer qStr.Close()
|
||||
var isSubmittedAndChecked bool = false
|
||||
|
||||
err = qStr.QueryRow(b.CounterId).Scan(&isSubmittedAndChecked)
|
||||
if err == sql.ErrNoRows {
|
||||
// No rows found ==> not even submitted
|
||||
return false
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
slog.Warn("Unexpected error when executing SQL Statement", "error", err)
|
||||
}
|
||||
return isSubmittedAndChecked
|
||||
}
|
||||
|
||||
func (b *Booking) Insert() error {
|
||||
if !checkLastBooking(*b) {
|
||||
return SameBookingError{}
|
||||
|
||||
Reference in New Issue
Block a user