Skip to content

Commit

Permalink
Merge pull request #3 from ahmetalpbalkan/master
Browse files Browse the repository at this point in the history
Added support for Sleep Measurements
  • Loading branch information
aouyar committed Jul 22, 2013
2 parents 26c9e8a + 474abdb commit 6bf4170
Showing 1 changed file with 54 additions and 4 deletions.
58 changes: 54 additions & 4 deletions healthgraph/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,16 @@ def get_weight_measurement_iter(self,
mod_date_max=mod_date_max,
descending=descending)

def get_sleep_measurement_iter(self,
date_min=None, date_max=None,
mod_date_min=None, mod_date_max=None,
descending=True):
return self._get_linked_resource(self._prop_dict['sleep'],
date_min=date_min,
date_max=date_max,
mod_date_min=mod_date_min,
mod_date_max=mod_date_max,
descending=descending)

class Profile(Resource):

Expand Down Expand Up @@ -640,7 +650,7 @@ def __init__(self, resource,


class WeightMeasurementFeedItem(FeedItem):

_prop_defs = {'uri': PropResourceLink('WeightMeasurement'),
'timestamp': parse_datetime,
'weight': float,
Expand All @@ -650,22 +660,62 @@ class WeightMeasurementFeedItem(FeedItem):
'mass_weight': float,
'bmi': float}
_prop_main = ('timestamp',)

def __init__(self, data, session=None):
super(WeightMeasurementFeedItem, self).__init__(data, session=session)


class WeightMeasurementIter(ResourceFeedIter):

_content_type = content_types.WEIGHT_MEASUREMENT_FEED
_item_cls = WeightMeasurementFeedItem

def __init__(self, resource,
date_min=None, date_max=None,
mod_date_min=None, mod_date_max=None,
descending=True,
session=None):
super(WeightMeasurementIter, self).__init__(resource,
date_min=date_min,
date_max=date_max,
mod_date_min=mod_date_min,
mod_date_max=mod_date_max,
descending=descending,
session=session)


class SleepMeasurementFeedItem(FeedItem):

_prop_defs = {'uri': PropResourceLink('SleepMeasurement'),
'timestamp': parse_datetime,
'total_sleep': float,
'rem': float,
'deep': float,
'light': float,
'awake': float,
'times_woken': float,
'source': None,
'previous': None,
'next': None,
# nearest_* fields for other types are omitted for now
}
_prop_main = ('timestamp',)

def __init__(self, data, session=None):
super(SleepMeasurementFeedItem, self).__init__(data, session=session)


class SleepMeasurementIter(ResourceFeedIter):

_content_type = content_types.SLEEP_MEASUREMENT_FEED
_item_cls = SleepMeasurementFeedItem

def __init__(self, resource,
date_min=None, date_max=None,
mod_date_min=None, mod_date_max=None,
descending=True,
session=None):
super(WeightMeasurementIter, self).__init__(resource,
super(SleepMeasurementIter, self).__init__(resource,
date_min=date_min,
date_max=date_max,
mod_date_min=mod_date_min,
Expand Down

0 comments on commit 6bf4170

Please sign in to comment.