-
Notifications
You must be signed in to change notification settings - Fork 7
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
new sleep disturbance event #1861
base: master
Are you sure you want to change the base?
Conversation
@@ -18,7 +18,8 @@ | |||
GOT_OUT_OF_BED(13), | |||
WOKE_UP(14), | |||
ALARM_RANG(15), | |||
UNKNOWN(16); | |||
SLEEP_DISTURBANCE(16), | |||
UNKNOWN(17); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't change the enum values if you can avoid it.
@@ -28,9 +28,11 @@ | |||
public final static String ALARM_NOT_SO_SMART_MESSAGE = "Your Smart Alarm rang at **%s**."; | |||
public final static String ALARM_SMART_MESSAGE = "Your Smart Alarm rang at **%s**.\nYou set it to wake you up by **%s**."; | |||
public final static String NOISE_MESSAGE = "There was a noise disturbance."; | |||
public final static String SLEEP_DISTURBANCE_MESSAGE = "Your sleep was interrupted."; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Has this been approved by product/copy/james?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checked it with copy/product. Consulting with Matt Walker following James' advices
} | ||
|
||
//Finds intances where the pill recorded 15seconds + of motion within a 4 minute window | ||
public HashMap<Long, Long> getSleepDisturbances(final List<TrackerMotion> trackerMotions){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use Map<Long, Long>
instead of the more specific HashMap
long previousMotionTS = 0L; | ||
|
||
List<TrackerMotion> trackerMotionWindowCurrent = new ArrayList<>(); | ||
final HashMap<Long,Integer> sleepDisturbances = new HashMap<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
|
||
currentDisturbanceEndTS = currentTS; | ||
int onDurationSum = trackerMotionCurrent.onDurationInSeconds.intValue(); | ||
if (!trackerMotionWindowPrevious.isEmpty()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe that some of this would benefit from being refactored. It's a little too much of twisted logic to be easily readable.
@@ -161,7 +163,11 @@ public Integer categorizeSleepDepth(final Integer sleepDepth) { | |||
return positiveMotions; | |||
} | |||
|
|||
public List<MotionEvent> generateMotionEvents(final List<TrackerMotion> trackerMotions) { | |||
public List<MotionEvent> generateMotionEvents(final List<TrackerMotion> trackerMotions, final boolean hasSleepDisturbance) { | |||
int minSleepDepth = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
put comments about why min sleep depth is added
@@ -476,6 +482,37 @@ public Integer getMaxSVM(final List<TrackerMotion> amplitudes){ | |||
return result; | |||
} | |||
|
|||
public List<Event> cleanEventWindow(final List<Event> eventList){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add comments for what this does and why it's here
@@ -1457,6 +1492,109 @@ public Insight generateInSleepSoundInsight(final int soundEventCount) { | |||
return events; | |||
} | |||
|
|||
public List<Event> getSleepDisturbanceEvents(final OneDaysTrackerMotion oneDaysTrackerMotion, final Long sleepTime, final Long wakeTime, final TimeZoneOffsetMap timeZoneOffsetMap){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
describe algo briefly in comments
New event to label possible wake events during sleep based on heuristic classifier.
https://hello.hackpad.com/Sleep-Disturbance-Event-igLaLwPeAqE