Exemple #1
0
def import_overdue_tasks(
    todoist_auth_token, beeminder_auth_token, target_goal
):
    beeminder_goal = json.loads(
        requests.get(
            "https://www.beeminder.com/api/v1/users/me/goals/%s.json" % (
                target_goal,), params={
                    "auth_token": beeminder_auth_token
                }
        ).text
    )

    now = time()
    today = datetime.now().strftime("%Y-%m-%d")
    tasks = fetch_overdue_tasks(todoist_auth_token)
    if tasks:
        datapoints = []
        for task in tasks:
            dp = {
                'value': 1,
                'comment': task['content'],
                'timestamp': now,
                'requestid': hashlib.sha1(':'.join((
                    today,
                    beeminder_goal['id'],
                    str(task['id']),
                ))).hexdigest()[:16]
            }
            datapoints.append(dp)
        beeminder.submit_datapoints(
            datapoints=datapoints,
            auth_token=beeminder_auth_token,
            target_goal=target_goal
        )
Exemple #2
0
def import_overdue_tasks(todoist_auth_token, beeminder_auth_token,
                         target_goal):
    beeminder_goal = json.loads(
        requests.get(
            "https://www.beeminder.com/api/v1/users/me/goals/%s.json" %
            (target_goal, ),
            params={
                "auth_token": beeminder_auth_token
            }).text)

    now = time()
    today = datetime.now().strftime("%Y-%m-%d")
    tasks = fetch_overdue_tasks(todoist_auth_token)
    if tasks:
        datapoints = []
        for task in tasks:
            dp = {
                'value':
                1,
                'comment':
                task['content'],
                'timestamp':
                now,
                'requestid':
                hashlib.sha1(':'.join((
                    today,
                    beeminder_goal['id'],
                    str(task['id']),
                ))).hexdigest()[:16]
            }
            datapoints.append(dp)
        beeminder.submit_datapoints(datapoints=datapoints,
                                    auth_token=beeminder_auth_token,
                                    target_goal=target_goal)
def import_karma(todoist_auth_token, beeminder_auth_token, target_goal):
    now = time()
    karma = get_karma(todoist_auth_token)
    beeminder.submit_datapoints(datapoints=[{
        'value': karma,
        'timestamp': now,
    }],
                                auth_token=beeminder_auth_token,
                                target_goal=target_goal)
def import_karma(
    todoist_auth_token, beeminder_auth_token, target_goal
):
    now = time()
    karma = get_karma(todoist_auth_token)
    beeminder.submit_datapoints(
        datapoints=[{
            'value': karma,
            'timestamp': now,
        }],
        auth_token=beeminder_auth_token,
        target_goal=target_goal
    )
def apply_backpressure(auth_token, max_days, target_goal):
    date_string = datetime.now().strftime("%Y-%m-%d")
    timestamp = time.time()

    datapoints = []
    for goal, days in impending_goals(
        auth_token=auth_token, max_days=max_days
    ):
        if goal == target_goal:
            continue

        requestid = hashlib.sha1(date_string + ":" + goal).hexdigest()[:16]
        datapoint = {
            'requestid': requestid,
            'timestamp': timestamp,
            'value': 1,
            'comment': "Goal %s has %d days remaining" % (goal, days),
        }
        datapoints.append(datapoint)
    submit_datapoints(
        datapoints=datapoints, target_goal=target_goal, auth_token=auth_token)
Exemple #6
0
def apply_backpressure(auth_token, max_days, target_goal):
    date_string = datetime.now().strftime("%Y-%m-%d")
    timestamp = time.time()

    datapoints = []
    for goal, days in impending_goals(auth_token=auth_token,
                                      max_days=max_days):
        if goal == target_goal:
            continue

        requestid = hashlib.sha1(date_string + ":" + goal).hexdigest()[:16]
        datapoint = {
            'requestid': requestid,
            'timestamp': timestamp,
            'value': 1,
            'comment': "Goal %s has %d days remaining" % (goal, days),
        }
        datapoints.append(datapoint)
    submit_datapoints(datapoints=datapoints,
                      target_goal=target_goal,
                      auth_token=auth_token)