Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BACK-2520] include pump sleep schedule #678

Merged
merged 9 commits into from
Nov 8, 2023

Conversation

jh-bate
Copy link
Contributor

@jh-bate jh-bate commented Nov 1, 2023

see tidepool-org/TidepoolApi#78

NOTE:

  • changed to be a map to match how other pump data works in the platform
  • to be resolved for SleepSchedulesMidnightOffset millisecond versus second debate related to the pump settings override duration.

Copy link
Member

@gniezen gniezen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My Go knowledge is not too great, so I'll leave it to @darinkrauss to comment on the more technical details, but the only issue I see is with the capitalization of days of the week as it's currently implemented.

package common

const (
DaySunday = "sunday"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like I capitalized the days of the week in the API PR and in the implementation. Not sure why we changed that, as I remember having it lowercase initially.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gniezen So this is correct here, right? I think we want to keep lowercase to maintain compatability with similar use in Dexcom alert schedules

Copy link
Member

@gniezen gniezen Nov 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@darinkrauss No, Uploader uploads sleep schedules with days of the week capitalized.

Are Dexcom alert schedules currently being uploaded from anywhere? I don't think we have a ticket for Uploader yet.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, Dexcom alert schedules are currently uploaded via the Dexcom Account Connection (and have been for years).

When you say "Uploader uploads sleep schedules with days of the week capitalized", do you mean to Jellyfish?

It'd be great if we could get this consistent (specifically, all use lowercase), but if that's going to be too much trouble...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you say "Uploader uploads sleep schedules with days of the week capitalized", do you mean to Jellyfish?
Yes.

I guess this could be one more thing we add to the migration? If we're changing bolus to boluses, we could also changed Monday to monday. It's an easy change in Uploader.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I suppose we should do this. One more thing to add to the list. @jh-bate

I wouldn't be surprised if we find other issues once you (@gniezen) actually start uploading via Platform. Considering the lack of validation in Jellyfish (and the validation in Platform), there will probably be other discrepancies that we'll have to resolve.

validator.Bool("enabled", s.Enabled).Exists()
if s.Enabled != nil {
if *s.Enabled {
validator.StringArray("days", s.Days).Exists().EachOneOf(common.DaysOfWeek()...).EachUnique()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! 👍

Copy link
Contributor

@darinkrauss darinkrauss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good. A few comments.

package common

const (
DaySunday = "sunday"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gniezen So this is correct here, right? I think we want to keep lowercase to maintain compatability with similar use in Dexcom alert schedules

@@ -185,6 +187,9 @@ func (p *Pump) Validate(validator structure.Validator) {
if p.OverridePresets != nil {
p.OverridePresets.Validate(validator.WithReference("overridePresets"), unitsBloodGlucose)
}
if p.SleepSchedules != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add SleepSchedule to Normalize, too, even if it is a NOP, for consistency.


"github.com/tidepool-org/platform/data/types/common"
"github.com/tidepool-org/platform/structure"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nit] Delete blank line.

)

const (
SleepSchedulesMidnightOffsetMaximum = 86400
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should hold off on this until we decide the millisecond versus second debate related to the pump settings override duration.

}

func (s *SleepScheduleMap) Validate(validator structure.Validator) {
for _, name := range s.sortedNames() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to validate the length is less than some maximum. The document says "0 < len <= 10", but that was somewhat arbitrary.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ended out not doing that as it didn't seem consistent with the other pumpSettings types from what I could see. I did see any of the maps enforcing a length

validator.Int("end", s.End).Exists().InRange(SleepSchedulesMidnightOffsetMinimum, SleepSchedulesMidnightOffsetMaximum)
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want a Normalize like:

func (a *AlertScheduleSettings) Normalize(normalizer structure.Normalizer) {
	if a.DaysOfWeek != nil {
		sort.Sort(DaysOfWeekByAlertScheduleSettingsDayIndex(*a.DaysOfWeek))
	}
}

dataTypesCommon "github.com/tidepool-org/platform/data/types/common"
dataTypesSettingsPump "github.com/tidepool-org/platform/data/types/settings/pump"
"github.com/tidepool-org/platform/pointer"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nit] Delete blank line.

@@ -0,0 +1,88 @@
package test
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Name of file to sleep_schedule.go?

"fmt"

dataTypesSettingsPump "github.com/tidepool-org/platform/data/types/settings/pump"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nit] Delete blank line.

@jh-bate jh-bate changed the base branch from master to jellyfish-migration-updates_0 November 8, 2023 21:57
@jh-bate jh-bate merged commit b2242ed into jellyfish-migration-updates_0 Nov 8, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants