summaryrefslogtreecommitdiffstats
path: root/server/dashboard.go
diff options
context:
space:
mode:
authorSam Anthony <sam@samanthony.xyz>2024-11-29 15:17:06 -0500
committerSam Anthony <sam@samanthony.xyz>2024-11-29 15:17:06 -0500
commitcee1d301809ec0b517962816b1b232c22a41eb3b (patch)
tree767c424653b71555919ae81261d0300aefc1faf0 /server/dashboard.go
parent6c8ae5c3a0d40c34a8db1aa4eac27734c321ca7b (diff)
downloadsoen422-cee1d301809ec0b517962816b1b232c22a41eb3b.zip
server: record duty cycle over time
Diffstat (limited to 'server/dashboard.go')
-rw-r--r--server/dashboard.go10
1 files changed, 6 insertions, 4 deletions
diff --git a/server/dashboard.go b/server/dashboard.go
index 1dca024..a31625b 100644
--- a/server/dashboard.go
+++ b/server/dashboard.go
@@ -24,7 +24,7 @@ type Dashboard struct {
type DashboardHandler struct {
target share.Val[Humidity]
building Building
- dutyCycle share.Val[DutyCycle]
+ dutyCycle Record[DutyCycle]
}
func (h DashboardHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
@@ -56,10 +56,12 @@ func (h DashboardHandler) buildDashboard() Dashboard {
average = -1
}
+ c := make(chan Entry[DutyCycle])
+ h.dutyCycle.getRecent <- c
var duty DutyCycle
- if dutyp, ok := h.dutyCycle.TryGet(); ok {
- duty = *dutyp
- } else {
+ if e, ok := <-c; ok {
+ duty = e.v
+ } else {
duty = -1
}