Exemplo n.º 1
0
    def test_get_tasks_completed_between(self):
        user = UserFactory.create()
        TaskRunFactory.create(user=user, created='2000-01-01T00:00:00.000')

        beg = '1999-01-01T00:00:00.000'
        end = '2001-01-01T00:00:00.000'
        task_runs = cached_users.get_tasks_completed_between(
            user.id, beginning_time_utc=beg, end_time_utc=end)
        assert len(task_runs) == 1

        beg = '2001-01-01T00:00:00.000'
        end = '2002-01-01T00:00:00.000'
        task_runs = cached_users.get_tasks_completed_between(
            user.id, beginning_time_utc=beg, end_time_utc=end)
        assert len(task_runs) == 0

        beg = '1999-01-01T00:00:00.000'
        end = None
        task_runs = cached_users.get_tasks_completed_between(
            user.id, beginning_time_utc=beg, end_time_utc=end)
        assert len(task_runs) == 1

        beg = '2001-01-01T00:00:00.000'
        end = None
        task_runs = cached_users.get_tasks_completed_between(
            user.id, beginning_time_utc=beg, end_time_utc=end)
        assert len(task_runs) == 0
Exemplo n.º 2
0
def recent_tasks(name):
    current_app.logger.debug('recent_tasks: {}'.format(name))
    start_time_utc = request.args.get('start')
    if (not start_time_utc) or (not utc_dt_re.search(start_time_utc)):
        abort(400)
    user = user_repo.get_by_name(name)
    recent = cached_users.get_tasks_completed_between(user.id, beginning_time_utc=start_time_utc[:-1])
    return jsonify(dict(count=len(recent)))