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

    headers = {'Authorization' : 'Bearer {0}'.format(access_token)}
    r = requests.get('https://jawbone.com/nudge/api/users/@me/meals',
                     headers=headers)

    for i in range(DAYS_BACK):
        day = timedelta(days=i) - today_utc()
        resp = r.json()
        meals = resp['data']['items']
        day_date = day.date()
        today_fmt = int(day_date.strftime('%Y%m%d'))
        today_meals = filter(lambda m: m['date'] == today_fmt, meals)
        caffeine = sum([m['details']['caffeine'] for m in today_meals])

        if caffeine == 0:
            logger.info('Caffeine not found on {0}, not saving.'.format(day_date))
        else:
            gauge.save(day, caffeine)
            logger.info('Saved {0}mg. caffeine  on {1}'.format(caffeine, day_date))
dataset/ETHPy150Open ahmetalpbalkan/personal-dashboard/tasks/jawboneup.py/caffeine/swapped operands of `-`