Refine arrival filters and demo date behavior

This commit is contained in:
sas.fajri
2026-04-30 16:11:20 +07:00
parent af7e0d3560
commit c6d3939592
4 changed files with 57 additions and 7 deletions

View File

@@ -5,6 +5,7 @@ import (
"fmt"
"sort"
"strings"
"time"
)
type StationBadge struct {
@@ -141,7 +142,10 @@ func GetStationProgress(mcuID int, date string) (map[int][]StationBadge, error)
sp.Mcu_StationProgressPreregisterID,
sp.Mcu_StationProgressStationName,
CASE
WHEN sp.Mcu_StationProgressDoneAt IS NOT NULL THEN 'success'
WHEN sp.Mcu_StationProgressSource = 'lab'
AND sp.Mcu_StationProgressReceiveAt IS NOT NULL THEN 'success'
WHEN sp.Mcu_StationProgressSource = 'nonlab'
AND sp.Mcu_StationProgressDoneAt IS NOT NULL THEN 'success'
WHEN sp.Mcu_StationProgressProcessAt IS NOT NULL
OR sp.Mcu_StationProgressReceiveAt IS NOT NULL
OR sp.Mcu_StationProgressSamplingAt IS NOT NULL THEN 'warning'
@@ -293,6 +297,12 @@ func activeDateOrLatest(dates []string, selected string, fallback string) string
}
}
}
today := time.Now().Format("2006-01-02")
for _, d := range dates {
if d == today {
return today
}
}
if len(dates) > 0 {
return dates[0]
}