mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-11-10 04:54:03 -08:00
fix(withings): pick today's steps
This commit is contained in:
parent
8426f81e71
commit
7029013fd8
|
@ -179,8 +179,15 @@ func (w *Withings) getActivities() bool {
|
|||
if err != nil || len(data.Body.Activities) == 0 {
|
||||
return false
|
||||
}
|
||||
w.Steps = data.Body.Activities[0].Steps
|
||||
return true
|
||||
today := time.Now().Format("2006-01-02")
|
||||
for _, activity := range data.Body.Activities {
|
||||
if activity.Date != today {
|
||||
continue
|
||||
}
|
||||
w.Steps = activity.Steps
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (w *Withings) getSleep() bool {
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
"oh-my-posh/mock"
|
||||
"oh-my-posh/properties"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
mock2 "github.com/stretchr/testify/mock"
|
||||
|
@ -84,8 +85,13 @@ func TestWithingsSegment(t *testing.T) {
|
|||
WithingsData: &WithingsData{
|
||||
Body: &Body{
|
||||
Activities: []*Activity{
|
||||
{
|
||||
Steps: 5066,
|
||||
Date: time.Now().AddDate(0, 0, -1).Format("2006-01-02"),
|
||||
},
|
||||
{
|
||||
Steps: 7077,
|
||||
Date: time.Now().Format("2006-01-02"),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -127,6 +133,7 @@ func TestWithingsSegment(t *testing.T) {
|
|||
Activities: []*Activity{
|
||||
{
|
||||
Steps: 976,
|
||||
Date: time.Now().Format("2006-01-02"),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue