added from and to times to team view fixes #4, #5

This commit is contained in:
2025-03-27 12:21:58 +01:00
parent d9e0bd7bdf
commit b43783356f
7 changed files with 263 additions and 91 deletions

View File

@@ -11,6 +11,8 @@ type WorkDay struct {
Bookings []Booking `json:"bookings"`
workTime time.Duration
pauseTime time.Duration
TimeFrom time.Time
TimeTo time.Time
}
func (d *WorkDay) GetWorkDays(card_uid string, tsFrom, tsTo time.Time) []WorkDay {
@@ -37,7 +39,8 @@ func (d *WorkDay) GetWorkDays(card_uid string, tsFrom, tsTo time.Time) []WorkDay
)
SELECT
work_date,
MIN(timestamp) AS time_from,
MAX(timestamp) AS time_to,
-- Total work time per day
COALESCE(
EXTRACT(EPOCH FROM SUM(
@@ -78,7 +81,7 @@ func (d *WorkDay) GetWorkDays(card_uid string, tsFrom, tsTo time.Time) []WorkDay
defer rows.Close()
for rows.Next() {
var workDay WorkDay
if err := rows.Scan(&workDay.Day, &workSec, &pauseSec); err != nil {
if err := rows.Scan(&workDay.Day, &workDay.TimeFrom, &workDay.TimeTo, &workSec, &pauseSec); err != nil {
log.Println("Error scanning row!", err)
return workDays
}