コード例 #1
0
ファイル: views.py プロジェクト: MMohan1/djangoproject.com
def get_user_stats(user):
    c = cache.get_cache('default')
    key = 'user_vital_status:%s' % hashlib.md5(user.username).hexdigest()
    info = c.get(key)
    if info is None:
        info = trac_stats.get_user_stats(user.username)
        # Hide any stat with a value = 0 so that we don't accidentally insult
        # non-contributors.
        for k, v in info.items():
            if v == 0:
                info.pop(k)
        c.set(key, info, 60*60)
    return info
コード例 #2
0
def get_user_stats(user):
    c = cache.get_cache('default')
    key = 'user_vital_status:%s' % hashlib.md5(user.username).hexdigest()
    info = c.get(key)
    if info is None:
        info = trac_stats.get_user_stats(user.username)
        # Hide any stat with a value = 0 so that we don't accidentally insult
        # non-contributors.
        for k, v in info.items():
            if v == 0:
                info.pop(k)
        c.set(key, info, 60 * 60)
    return info