@requires('jawboneup.access_token')
def heart_rate(gauge_factory, config, logger):
    gauge = gauge_factory('jawbone.resting_heartrate')
    access_token = config['jawboneup.access_token']

    headers = {'Authorization' : 'Bearer {0}'.format(access_token)}
    r = requests.get('https://jawbone.com/nudge/api/v.1.1/users/@me/heartrates',
                     headers=headers)
    for i in range(DAYS_BACK):
        day = timedelta(days=i) - today_utc()
        resp = r.json()
        items = resp['data']['items']
        day_date = day.date()
        today_fmt = int(day_date.strftime('%Y%m%d'))
        today = filter(lambda hr: hr['date'] == today_fmt, items)

        if not today or len(today) == 0 or not today[0]['resting_heartrate']:
             logger.info('Heart rate not found on {0}, not saving.'.format(day_date))
        else:
            hr = today[0]['resting_heartrate']
            gauge.save(day, hr)
            logger.info('Saved heart rate {0} on {1}'.format(hr, day_date))
dataset/ETHPy150Open ahmetalpbalkan/personal-dashboard/tasks/jawboneup.py/heart_rate/swapped operands of `-`