File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed
Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change 22import numpy as np
33from ..feature_types import secondary_feature
44from ..primary .screen_active import screen_active
5+ from ..raw .device_state import device_state
56
67MS_IN_A_DAY = 86400000
78@secondary_feature (
@@ -32,9 +33,17 @@ def screen_duration(**kwargs):
3233 value (float): The time (in ms) spent with the device screen on.
3334
3435 """
35- _screen_active = screen_active (** kwargs )
36- _screen_duration = np .sum ([active_bout ['duration' ] for active_bout in _screen_active ['data' ]])
36+
37+ _device_state = device_state (id = kwargs ['id' ],
38+ start = kwargs ['start' ],
39+ end = kwargs ['end' ],
40+ _limit = 1 )['data' ]
41+
3742 # screen duration should be None if there is no data
38- if _screen_active [ 'has_raw_data' ] == 0 :
43+ if len ( _device_state ) == 0 :
3944 _screen_duration = None
40- return {'timestamp' :kwargs ['start' ], 'value' : _screen_duration }
45+ else :
46+ _screen_active = screen_active (** kwargs )
47+ _screen_duration = np .sum ([active_bout ['duration' ] for active_bout in _screen_active ['data' ]])
48+
49+ return {'timestamp' : kwargs ['start' ], 'value' : _screen_duration }
You can’t perform that action at this time.
0 commit comments