fixed minor bugs + added loggin middleware
All checks were successful
Tests / Run Go Tests (push) Successful in 1m26s
All checks were successful
Tests / Run Go Tests (push) Successful in 1m26s
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -49,19 +49,16 @@ func GetDays(user User, tsFrom, tsTo time.Time, orderedForward bool) []IWorkDay
|
||||
}
|
||||
|
||||
for _, absentDay := range absences {
|
||||
// Kurzarbeit should be integrated in workday
|
||||
|
||||
// Check if there is already a day
|
||||
existingDay, ok := allDays[absentDay.Date().Format(time.DateOnly)]
|
||||
if !ok {
|
||||
allDays[absentDay.Date().Format(time.DateOnly)] = &absentDay
|
||||
continue
|
||||
}
|
||||
switch {
|
||||
case absentDay.AbwesenheitTyp.WorkTime < 0:
|
||||
if workDay, ok := allDays[absentDay.Date().Format(time.DateOnly)].(*WorkDay); ok {
|
||||
workDay.kurzArbeit = true
|
||||
workDay.kurzArbeitAbsence = absentDay
|
||||
}
|
||||
case !existingDay.IsEmpty():
|
||||
case ok && !existingDay.IsEmpty():
|
||||
allDays[absentDay.Date().Format(time.DateOnly)] = NewCompondDay(absentDay.Date(), existingDay, &absentDay)
|
||||
default:
|
||||
allDays[absentDay.Date().Format(time.DateOnly)] = &absentDay
|
||||
|
||||
@@ -331,7 +331,7 @@ func GetWorkDays(user User, tsFrom, tsTo time.Time) []WorkDay {
|
||||
if len(workDay.Bookings) == 1 && workDay.Bookings[0].CounterId == 0 {
|
||||
workDay.Bookings = []Booking{}
|
||||
}
|
||||
if len(workDay.Bookings) > 1 || !helper.IsWeekend(workDay.Date()) {
|
||||
if len(workDay.Bookings) >= 1 || !helper.IsWeekend(workDay.Date()) {
|
||||
workDays = append(workDays, workDay)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user