Esempio n. 1
0
def home():
    """Render home page with the cached projects and users."""
    page = 1
    per_page = current_app.config.get('APPS_PER_PAGE')
    if per_page is None:  # pragma: no cover
        per_page = 5
    d = {'top_projects': cached_projects.get_top(),
         'top_users': None}

    # Get all the categories with projects
    categories = cached_cat.get_used()
    d['categories'] = categories
    d['categories_projects'] = {}
    for c in categories:
        tmp_projects = cached_projects.get(c['short_name'], page, per_page)
        d['categories_projects'][c['short_name']] = rank(tmp_projects)

    # Add featured
    tmp_projects = cached_projects.get_featured('featured', page, per_page)
    if len(tmp_projects) > 0:
        featured = Category(name='Featured', short_name='featured')
        d['categories'].insert(0, featured)
        d['categories_projects']['featured'] = rank(tmp_projects)

    if (current_app.config['ENFORCE_PRIVACY']
            and current_user.is_authenticated()):
        if current_user.admin:
            d['top_users'] = cached_users.get_top()
    if not current_app.config['ENFORCE_PRIVACY']:
        d['top_users'] = cached_users.get_top()
    return render_template('/home/index.html', **d)
Esempio n. 2
0
def home():
    """Render home page with the cached projects and users."""
    page = 1
    per_page = current_app.config.get('APPS_PER_PAGE')
    if per_page is None:  # pragma: no cover
        per_page = 5
    d = {'top_projects': cached_projects.get_top(),
         'top_users': None}

    # Get all the categories with projects
    categories = cached_cat.get_used()
    d['categories'] = categories
    d['categories_projects'] = {}
    for c in categories:
        tmp_projects = cached_projects.get(c['short_name'], page, per_page)
        d['categories_projects'][c['short_name']] = rank(tmp_projects)

    # Add featured
    tmp_projects = cached_projects.get_featured('featured', page, per_page)
    if len(tmp_projects) > 0:
        featured = Category(name='Featured', short_name='featured')
        d['categories'].insert(0, featured)
        d['categories_projects']['featured'] = rank(tmp_projects)

    if (current_app.config['ENFORCE_PRIVACY']
            and current_user.is_authenticated()):
        if current_user.admin:
            d['top_users'] = cached_users.get_leaderboard(10)
    if not current_app.config['ENFORCE_PRIVACY']:
        d['top_users'] = cached_users.get_leaderboard(10)
    response = dict(template='/home/index.html', **d)
    return handle_content_type(response)
Esempio n. 3
0
def warm_cache():  # pragma: no cover
    """Background job to warm cache."""
    from pybossa.core import create_app
    app = create_app(run_as_server=False)
    projects_cached = []
    import pybossa.cache.projects as cached_projects
    import pybossa.cache.categories as cached_cat
    import pybossa.cache.users as cached_users
    import pybossa.cache.project_stats as stats
    from pybossa.util import rank
    from pybossa.core import user_repo

    def warm_project(_id, short_name, featured=False):
        if _id not in projects_cached:
            #cached_projects.get_project(short_name)
            #cached_projects.n_tasks(_id)
            #n_task_runs = cached_projects.n_task_runs(_id)
            #cached_projects.overall_progress(_id)
            #cached_projects.last_activity(_id)
            #cached_projects.n_completed_tasks(_id)
            #cached_projects.n_volunteers(_id)
            #cached_projects.browse_tasks(_id)
            #if n_task_runs >= 1000 or featured:
            #    # print ("Getting stats for %s as it has %s task runs" %
            #    #        (short_name, n_task_runs))
            stats.update_stats(_id, app.config.get('GEO'))
            projects_cached.append(_id)

    # Cache top projects
    projects = cached_projects.get_top()
    for p in projects:
        warm_project(p['id'], p['short_name'])

    # Cache 3 pages
    to_cache = 3 * app.config['APPS_PER_PAGE']
    projects = rank(cached_projects.get_all_featured('featured'))[:to_cache]
    for p in projects:
        warm_project(p['id'], p['short_name'], featured=True)

    # Categories
    categories = cached_cat.get_used()
    for c in categories:
        projects = rank(cached_projects.get_all(c['short_name']))[:to_cache]
        for p in projects:
            warm_project(p['id'], p['short_name'])
    # Users
    users = cached_users.get_leaderboard(app.config['LEADERBOARD'])
    for user in users:
        # print "Getting stats for %s" % user['name']
        print user_repo
        u = user_repo.get_by_name(user['name'])
        cached_users.get_user_summary(user['name'])
        cached_users.projects_contributed_cached(u.id)
        cached_users.published_projects_cached(u.id)
        cached_users.draft_projects_cached(u.id)

    return True
Esempio n. 4
0
def warm_cache():  # pragma: no cover
    """Background job to warm cache."""
    from pybossa.core import create_app
    app = create_app(run_as_server=False)
    projects_cached = []
    import pybossa.cache.projects as cached_projects
    import pybossa.cache.categories as cached_cat
    import pybossa.cache.users as cached_users
    import pybossa.cache.project_stats as stats
    from pybossa.util import rank
    from pybossa.core import user_repo

    def warm_project(_id, short_name, featured=False):
        if _id not in projects_cached:
            #cached_projects.get_project(short_name)
            #cached_projects.n_tasks(_id)
            #n_task_runs = cached_projects.n_task_runs(_id)
            #cached_projects.overall_progress(_id)
            #cached_projects.last_activity(_id)
            #cached_projects.n_completed_tasks(_id)
            #cached_projects.n_volunteers(_id)
            #cached_projects.browse_tasks(_id)
            #if n_task_runs >= 1000 or featured:
            #    # print ("Getting stats for %s as it has %s task runs" %
            #    #        (short_name, n_task_runs))
            stats.update_stats(_id, app.config.get('GEO'))
            projects_cached.append(_id)

    # Cache top projects
    projects = cached_projects.get_top()
    for p in projects:
        warm_project(p['id'], p['short_name'])

    # Cache 3 pages
    to_cache = 3 * app.config['APPS_PER_PAGE']
    projects = rank(cached_projects.get_all_featured('featured'))[:to_cache]
    for p in projects:
        warm_project(p['id'], p['short_name'], featured=True)

    # Categories
    categories = cached_cat.get_used()
    for c in categories:
        projects = rank(cached_projects.get_all(c['short_name']))[:to_cache]
        for p in projects:
            warm_project(p['id'], p['short_name'])
    # Users
    users = cached_users.get_leaderboard(app.config['LEADERBOARD'])
    for user in users:
        # print "Getting stats for %s" % user['name']
        print user_repo
        u = user_repo.get_by_name(user['name'])
        cached_users.get_user_summary(user['name'])
        cached_users.projects_contributed_cached(u.id)
        cached_users.published_projects_cached(u.id)
        cached_users.draft_projects_cached(u.id)

    return True
Esempio n. 5
0
    def test_it_gives_priority_to_uncompleted_projects(self):
        projects = [{'info': {}, 'n_tasks': 4L, 'short_name': 'uncompleted', 'name': u'uncompleted', 'overall_progress': 0L, 'n_volunteers': 1L},
                    {'info': {}, 'n_tasks': 4L, 'short_name': 'completed', 'name': u'completed', 'overall_progress': 100L, 'n_volunteers': 1L}]
        ranked = util.rank(projects)

        assert ranked[0]['name'] == "uncompleted"
        assert ranked[1]['name'] == "completed"
Esempio n. 6
0
    def test_it_penalizes_projects_with_test_in_the_name_or_short_name(self):
        projects = [{'info': {}, 'n_tasks': 4L, 'name': u'my test 123', 'short_name': u'123', 'overall_progress': 0L, 'n_volunteers': 1L},
                    {'info': {}, 'n_tasks': 246L, 'name': u'123', 'short_name': u'mytest123', 'overall_progress': 0L, 'n_volunteers': 1L},
                    {'info': {}, 'n_tasks': 246L, 'name': u'real', 'short_name': u'real', 'overall_progress': 0L, 'n_volunteers': 1L}]
        ranked = util.rank(projects)

        assert ranked[0]['name'] == "real"
Esempio n. 7
0
    def test_rank_by_recent_updates_or_contributions(self):
        today = datetime.utcnow()
        yesterday = today - timedelta(1)
        two_days_ago = today - timedelta(2)
        three_days_ago = today - timedelta(3)
        four_days_ago = today - timedelta(4)
        projects = [{'info': {},
                     'n_tasks': 1, 'name': u'last', 'short_name': u'a',
                     'overall_progress': 0, 'n_volunteers': 1,
                     'last_activity_raw': four_days_ago.strftime(
                         '%Y-%m-%dT%H:%M:%S.%f')},
                    {'info': {},
                     'n_tasks': 1, 'name': u'fourth', 'short_name': u'c',
                     'overall_progress': 0, 'n_volunteers': 1,
                     'last_activity_raw': three_days_ago.strftime(
                         '%Y-%m-%dT%H:%M:%S')},
                    {'info': {},
                     'n_tasks': 1, 'name': u'third', 'short_name': u'd',
                     'overall_progress': 0, 'n_volunteers': 1,
                     'updated': two_days_ago.strftime('%Y-%m-%dT%H:%M:%S.%f')},
                    {'info': {},
                     'n_tasks': 1, 'name': u'second', 'short_name': u'e',
                     'overall_progress': 0, 'n_volunteers': 1,
                     'updated': yesterday.strftime('%Y-%m-%dT%H:%M:%S')},
                    {'info': {},
                     'n_tasks': 1, 'name': u'first', 'short_name': u'e',
                     'overall_progress': 0, 'n_volunteers': 1,
                     'updated': today.strftime('%Y-%m-%dT%H:%M:%S.%f')}]
        ranked = util.rank(projects)

        assert ranked[0]['name'] == 'first', ranked[0]['name']
        assert ranked[1]['name'] == 'second', ranked[1]['name']
        assert ranked[2]['name'] == 'third', ranked[2]['name']
        assert ranked[3]['name'] == 'fourth', ranked[3]['name']
        assert ranked[4]['name'] == 'last', ranked[4]['name']
Esempio n. 8
0
    def test_rank_by_number_of_crafters(self):
        projects = [
            {'info': {},
             'n_tasks': 1, 'name': u'last', 'short_name': u'a',
             'overall_progress': 0, 'n_volunteers': 0},
            {'info': {},
             'n_tasks': 1, 'name': u'fifth', 'short_name': u'b',
             'overall_progress': 0, 'n_volunteers': 1},
            {'info': {},
             'n_tasks': 1, 'name': u'fourth', 'short_name': u'b',
             'overall_progress': 0, 'n_volunteers': 11},
            {'info': {},
             'n_tasks': 1, 'name': u'third', 'short_name': u'c',
             'overall_progress': 0, 'n_volunteers': 21},
            {'info': {},
             'n_tasks': 1, 'name': u'second', 'short_name': u'd',
             'overall_progress': 0, 'n_volunteers': 51},
            {'info': {},
             'n_tasks': 1, 'name': u'first', 'short_name': u'e',
             'overall_progress': 0, 'n_volunteers': 101}]
        ranked = util.rank(projects)

        assert ranked[0]['name'] == 'first'
        assert ranked[1]['name'] == 'second'
        assert ranked[2]['name'] == 'third'
        assert ranked[3]['name'] == 'fourth'
        assert ranked[4]['name'] == 'fifth'
        assert ranked[5]['name'] == 'last'
Esempio n. 9
0
def home():
    """Render home page with the cached projects and users."""
    page = 1
    per_page = current_app.config.get('APPS_PER_PAGE', 5)

    # Add featured
    tmp_projects = cached_projects.get_featured('featured', page, per_page)
    if len(tmp_projects) > 0:
        data = dict(featured=rank(tmp_projects))
    else:
        data = dict(featured=[])
    # Add historical contributions
    historical_projects = []
    projects = project_repo.get_all()
    data['projects'] = []
    for project in projects:
        if project.published == True:
            data['projects'].append(project)
    if current_user.is_authenticated():
        user_id = current_user.id
        historical_projects = cached_users.projects_contributed(
            user_id, order_by='last_contribution')[:3]
        data['historical_contributions'] = historical_projects
    response = dict(template='/home/index.html', **data)
    return handle_content_type(response)
Esempio n. 10
0
    def test_rank_by_recent_updates_or_contributions(self):
        today = datetime.utcnow()
        yesterday = today - timedelta(1)
        two_days_ago = today - timedelta(2)
        three_days_ago = today - timedelta(3)
        four_days_ago = today - timedelta(4)
        projects = [{'info': {},
                     'n_tasks': 1, 'name': u'last', 'short_name': u'a',
                     'overall_progress': 0, 'n_volunteers': 1,
                     'last_activity_raw': four_days_ago.strftime(
                         '%Y-%m-%dT%H:%M:%S.%f')},
                    {'info': {},
                     'n_tasks': 1, 'name': u'fourth', 'short_name': u'c',
                     'overall_progress': 0, 'n_volunteers': 1,
                     'last_activity_raw': three_days_ago.strftime(
                         '%Y-%m-%dT%H:%M:%S')},
                    {'info': {},
                     'n_tasks': 1, 'name': u'third', 'short_name': u'd',
                     'overall_progress': 0, 'n_volunteers': 1,
                     'updated': two_days_ago.strftime('%Y-%m-%dT%H:%M:%S.%f')},
                    {'info': {},
                     'n_tasks': 1, 'name': u'second', 'short_name': u'e',
                     'overall_progress': 0, 'n_volunteers': 1,
                     'updated': yesterday.strftime('%Y-%m-%dT%H:%M:%S')},
                    {'info': {},
                     'n_tasks': 1, 'name': u'first', 'short_name': u'e',
                     'overall_progress': 0, 'n_volunteers': 1,
                     'updated': today.strftime('%Y-%m-%dT%H:%M:%S.%f')}]
        ranked = util.rank(projects)

        assert ranked[0]['name'] == 'first', ranked[0]['name']
        assert ranked[1]['name'] == 'second', ranked[1]['name']
        assert ranked[2]['name'] == 'third', ranked[2]['name']
        assert ranked[3]['name'] == 'fourth', ranked[3]['name']
        assert ranked[4]['name'] == 'last', ranked[4]['name']
Esempio n. 11
0
    def test_rank_by_number_of_crafters(self):
        projects = [
            {'info': {},
             'n_tasks': 1, 'name': u'last', 'short_name': u'a',
             'overall_progress': 0, 'n_volunteers': 0},
            {'info': {},
             'n_tasks': 1, 'name': u'fifth', 'short_name': u'b',
             'overall_progress': 0, 'n_volunteers': 1},
            {'info': {},
             'n_tasks': 1, 'name': u'fourth', 'short_name': u'b',
             'overall_progress': 0, 'n_volunteers': 11},
            {'info': {},
             'n_tasks': 1, 'name': u'third', 'short_name': u'c',
             'overall_progress': 0, 'n_volunteers': 21},
            {'info': {},
             'n_tasks': 1, 'name': u'second', 'short_name': u'd',
             'overall_progress': 0, 'n_volunteers': 51},
            {'info': {},
             'n_tasks': 1, 'name': u'first', 'short_name': u'e',
             'overall_progress': 0, 'n_volunteers': 101}]
        ranked = util.rank(projects)

        assert ranked[0]['name'] == 'first'
        assert ranked[1]['name'] == 'second'
        assert ranked[2]['name'] == 'third'
        assert ranked[3]['name'] == 'fourth'
        assert ranked[4]['name'] == 'fifth'
        assert ranked[5]['name'] == 'last'
Esempio n. 12
0
    def test_it_gives_priority_to_projects_with_an_avatar(self):
        projects = [{'info': {}, 'n_tasks': 4L, 'short_name': 'noavatar', 'name': u'with avatar', 'overall_progress': 0L, 'n_volunteers': 1L},
                    {'info': {u'container': u'user_7', u'thumbnail': u'avatar.png'}, 'n_tasks': 4L, 'short_name': 'avatar', 'name': u'without avatar', 'overall_progress': 100L, 'n_volunteers': 1L}]
        ranked = util.rank(projects)

        assert ranked[0]['name'] == "with avatar"
        assert ranked[1]['name'] == "without avatar"
Esempio n. 13
0
def home():
    """Render home page with the cached projects and users."""
    page = 1
    per_page = current_app.config.get('APPS_PER_PAGE', 5)

    # Add featured
    tmp_projects = cached_projects.get_featured('featured', page, per_page)
    if len(tmp_projects) > 0:
        data = dict(featured=rank(tmp_projects))
    else:
        data = dict(featured=[])
    response = dict(template='/home/index.html', **data)
    return handle_content_type(response)
Esempio n. 14
0
def home():
    """Render home page with the cached projects and users."""
    page = 1
    per_page = current_app.config.get('APPS_PER_PAGE', 5)

    # Add featured
    tmp_projects = cached_projects.get_featured('featured', page, per_page)
    if len(tmp_projects) > 0:
        data = dict(featured=rank(tmp_projects))
    else:
        data = dict(featured=[])
    response = dict(template='/home/index.html', **data)
    return handle_content_type(response)
Esempio n. 15
0
    def test_rank_by_chosen_attribute(self):
        projects = [{
            'info': {},
            'n_tasks': 1,
            'name': 'last',
            'short_name': 'a',
            'overall_progress': 0,
            'n_volunteers': 10
        }, {
            'info': {},
            'n_tasks': 11,
            'name': 'fourth',
            'short_name': 'b',
            'overall_progress': 0,
            'n_volunteers': 25
        }, {
            'info': {},
            'n_tasks': 21,
            'name': 'third',
            'short_name': 'c',
            'overall_progress': 0,
            'n_volunteers': 15
        }, {
            'info': {},
            'n_tasks': 51,
            'name': 'second',
            'short_name': 'd',
            'overall_progress': 0,
            'n_volunteers': 1
        }, {
            'info': {},
            'n_tasks': 101,
            'name': 'first',
            'short_name': 'e',
            'overall_progress': 0,
            'n_volunteers': 5
        }]
        ranked = util.rank(projects, order_by='n_volunteers')

        assert ranked[0]['name'] == 'second'
        assert ranked[1]['name'] == 'first'
        assert ranked[2]['name'] == 'last'
        assert ranked[3]['name'] == 'third'
        assert ranked[4]['name'] == 'fourth'
Esempio n. 16
0
    def test_rank_by_chosen_attribute_reversed(self):
        projects = [{
            'info': {},
            'n_tasks': 1,
            'name': u'last',
            'short_name': u'a',
            'overall_progress': 0,
            'n_volunteers': 1
        }, {
            'info': {},
            'n_tasks': 11,
            'name': u'fourth',
            'short_name': u'b',
            'overall_progress': 0,
            'n_volunteers': 5
        }, {
            'info': {},
            'n_tasks': 21,
            'name': u'third',
            'short_name': u'c',
            'overall_progress': 0,
            'n_volunteers': 10
        }, {
            'info': {},
            'n_tasks': 51,
            'name': u'second',
            'short_name': u'd',
            'overall_progress': 0,
            'n_volunteers': 20
        }, {
            'info': {},
            'n_tasks': 101,
            'name': u'first',
            'short_name': u'e',
            'overall_progress': 0,
            'n_volunteers': 30
        }]
        ranked = util.rank(projects, order_by='n_volunteers', desc=True)

        assert ranked[0]['name'] == 'first'
        assert ranked[1]['name'] == 'second'
        assert ranked[2]['name'] == 'third'
        assert ranked[3]['name'] == 'fourth'
        assert ranked[4]['name'] == 'last'
Esempio n. 17
0
def home():
    """Render home page with the cached projects and users."""
    page = 1
    per_page = current_app.config.get('APPS_PER_PAGE', 5)

    # Add featured
    tmp_projects = cached_projects.get_featured('featured', page, per_page)
    if len(tmp_projects) > 0:
        data = dict(featured=rank(tmp_projects))
    else:
        data = dict(featured=[])
    # Add historical contributions
    historical_projects = []
    if current_user.is_authenticated:
        user_id = current_user.id
        historical_projects = cached_users.projects_contributed(user_id, order_by='last_contribution')[:3]
        data['historical_contributions'] = historical_projects
    response = dict(template='/home/index.html', **data)
    return handle_content_type(response)
Esempio n. 18
0
def home():
    """Render home page with the cached projects and users."""
    page = 1
    per_page = current_app.config.get('APPS_PER_PAGE', 5)

    # Add featured
    tmp_projects = cached_projects.get_featured('featured', page, per_page)
    if len(tmp_projects) > 0:
        data = dict(featured=rank(tmp_projects))
    else:
        data = dict(featured=[])

    # Allow user to change locale on welcome page
    if current_user.is_authenticated:
        # Change locale
        locale_form = UpdateLocaleForm(obj=current_user)
        locale_form.set_locales(current_app.config['LOCALES'])
        data['locale_form'] = locale_form

    response = dict(template='/home/index.html', **data)
    return handle_content_type(response)
Esempio n. 19
0
def home():
    """Render home page with the cached projects and users."""
    page = 1
    per_page = current_app.config.get('APPS_PER_PAGE', 5)

    # Add featured
    tmp_projects = cached_projects.get_featured('featured', page, per_page)
    if len(tmp_projects) > 0:
        data = dict(featured=rank(tmp_projects))
    else:
        data = dict(featured=[])
    # Add historical contributions
    historical_projects = []
    if current_user.is_authenticated:
        user_id = current_user.id
        historical_projects = cached_users.projects_contributed(user_id, order_by='last_contribution')[:3]
        data['historical_contributions'] = historical_projects
        rank_and_score = cached_users.rank_and_score(user_id)
        current_user.rank = rank_and_score['rank']
    response = dict(template='/home/index.html', **data)
    #return handle_content_type(response)
    return redirect('/project/category/mkplaygames', code=302)
Esempio n. 20
0
    def test_rank_by_chosen_attribute_reversed(self):
        projects = [
            {'info': {},
             'n_tasks': 1, 'name': u'last', 'short_name': u'a',
             'overall_progress': 0, 'n_volunteers': 1},
            {'info': {},
             'n_tasks': 11, 'name': u'fourth', 'short_name': u'b',
             'overall_progress': 0, 'n_volunteers': 5},
            {'info': {},
             'n_tasks': 21, 'name': u'third', 'short_name': u'c',
             'overall_progress': 0, 'n_volunteers': 10},
            {'info': {},
             'n_tasks': 51, 'name': u'second', 'short_name': u'd',
             'overall_progress': 0, 'n_volunteers': 20},
            {'info': {},
             'n_tasks': 101, 'name': u'first', 'short_name': u'e',
             'overall_progress': 0, 'n_volunteers': 30}]
        ranked = util.rank(projects, order_by='n_volunteers', desc=True)

        assert ranked[0]['name'] == 'first'
        assert ranked[1]['name'] == 'second'
        assert ranked[2]['name'] == 'third'
        assert ranked[3]['name'] == 'fourth'
        assert ranked[4]['name'] == 'last'
Esempio n. 21
0
                    {'info': {}, 'n_tasks': 1L, 'name': u'third', 'short_name': u'c', 'overall_progress': 0L, 'n_volunteers': 21L},
                    {'info': {}, 'n_tasks': 1L, 'name': u'second', 'short_name': u'd', 'overall_progress': 0L, 'n_volunteers': 51L},
                    {'info': {}, 'n_tasks': 1L, 'name': u'first', 'short_name': u'e', 'overall_progress': 0L, 'n_volunteers': 101L}]
        ranked = util.rank(projects)

        assert ranked[0]['name'] == 'first'
        assert ranked[1]['name'] == 'second'
        assert ranked[2]['name'] == 'third'
        assert ranked[3]['name'] == 'fourth'
        assert ranked[4]['name'] == 'fifth'
        assert ranked[5]['name'] == 'last'

    def test_rank_by_recent_updates_or_contributions(self):
        today = datetime.utcnow()
        yesterday = today - timedelta(1)
        two_days_ago = today - timedelta(2)
        three_days_ago = today - timedelta(3)
        four_days_ago = today - timedelta(4)
        projects = [{'info': {}, 'n_tasks': 1L, 'name': u'last', 'short_name': u'a', 'overall_progress': 0L, 'n_volunteers': 1L, 'last_activity_raw': four_days_ago.strftime('%Y-%m-%dT%H:%M:%S.%f')},
                    {'info': {}, 'n_tasks': 1L, 'name': u'fourth', 'short_name': u'c', 'overall_progress': 0L, 'n_volunteers': 1L, 'last_activity_raw': three_days_ago.strftime('%Y-%m-%dT%H:%M:%S')},
                    {'info': {}, 'n_tasks': 1L, 'name': u'third', 'short_name': u'd', 'overall_progress': 0L, 'n_volunteers': 1L, 'updated': two_days_ago.strftime('%Y-%m-%dT%H:%M:%S.%f')},
                    {'info': {}, 'n_tasks': 1L, 'name': u'second', 'short_name': u'e', 'overall_progress': 0L, 'n_volunteers': 1L, 'updated': yesterday.strftime('%Y-%m-%dT%H:%M:%S')},
                    {'info': {}, 'n_tasks': 1L, 'name': u'first', 'short_name': u'e', 'overall_progress': 0L, 'n_volunteers': 1L, 'updated': today.strftime('%Y-%m-%dT%H:%M:%S.%f')}]
        ranked = util.rank(projects)

        assert ranked[0]['name'] == 'first', ranked[0]['name']
        assert ranked[1]['name'] == 'second', ranked[1]['name']
        assert ranked[2]['name'] == 'third', ranked[2]['name']
        assert ranked[3]['name'] == 'fourth', ranked[3]['name']
        assert ranked[4]['name'] == 'last', ranked[4]['name']