fixed error when only one booking was inserted

This commit is contained in:
2025-05-20 14:47:24 +02:00
parent f5e2e32545
commit d955cb02b8
3 changed files with 4 additions and 4 deletions

View File

@@ -26,7 +26,7 @@ func (d *WorkDay) GetWorkDays(card_uid string, tsFrom, tsTo time.Time) []WorkDay
qStr, err := DB.Prepare(`
WITH all_days AS (
SELECT generate_series($2, $3, INTERVAL '1 day')::DATE AS work_date
SELECT generate_series($2::DATE, $3::DATE - INTERVAL '1 day', INTERVAL '1 day')::DATE AS work_date
),
ordered_bookings AS (
SELECT
@@ -155,7 +155,7 @@ func (d *WorkDay) calcPauseTime() {
// Gets the duration someone worked that day
func (d *WorkDay) getWorkTime() {
if len(d.Bookings) <= 1 && d.Bookings[0].CounterId == 0 {
if len(d.Bookings) < 1 {
return
}
var workTime, pauseTime time.Duration