Exemplo n.º 1
0
def test_skip_cache():
    eq_(getattr(context._locals, 'skip_cache', False), False)
    with context.skip_cache():
        eq_(context._locals.skip_cache, True)
        with context.skip_cache():
            eq_(context._locals.skip_cache, True)
        eq_(context._locals.skip_cache, True)
    eq_(context._locals.skip_cache, False)
Exemplo n.º 2
0
def test_skip_cache():
    eq_(getattr(context._locals, 'skip_cache', False), False)
    with context.skip_cache():
        eq_(context._locals.skip_cache, True)
        with context.skip_cache():
            eq_(context._locals.skip_cache, True)
        eq_(context._locals.skip_cache, True)
    eq_(context._locals.skip_cache, False)
Exemplo n.º 3
0
def test_skip_cache():
    ok_(hasattr(models._locals, 'skip_cache'))
    eq_(getattr(models._locals, 'skip_cache'),
        not settings.CACHE_MACHINE_ENABLED)
    models._locals.skip_cache = False
    with models.skip_cache():
        eq_(models._locals.skip_cache, True)
        with models.skip_cache():
            eq_(models._locals.skip_cache, True)
        eq_(models._locals.skip_cache, True)
    eq_(models._locals.skip_cache, False)
Exemplo n.º 4
0
    def get_performance(cls, user):
        """Returns sum of reviewer points."""
        key = cls.get_key('get_performance:%s' % user.id)
        val = cache.get(key)
        if val is not None:
            return val

        sql = """
             SELECT `reviewer_scores`.*,
                    SUM(`reviewer_scores`.`score`) AS `total`
             FROM `reviewer_scores`
             LEFT JOIN `addons` ON (`reviewer_scores`.`addon_id`=`addons`.`id`)
             WHERE `reviewer_scores`.`user_id` = %s
             ORDER BY `total` DESC
        """
        with skip_cache():
            val = list(ReviewerScore.objects.raw(sql, [user.id]))
        cache.set(key, val, None)
        return val
Exemplo n.º 5
0
    def get_performance(cls, user):
        """Returns sum of reviewer points."""
        key = cls.get_key('get_performance:%s' % user.id)
        val = cache.get(key)
        if val is not None:
            return val

        sql = """
             SELECT `reviewer_scores`.*,
                    SUM(`reviewer_scores`.`score`) AS `total`
             FROM `reviewer_scores`
             LEFT JOIN `addons` ON (`reviewer_scores`.`addon_id`=`addons`.`id`)
             WHERE `reviewer_scores`.`user_id` = %s
             ORDER BY `total` DESC
        """
        with skip_cache():
            val = list(ReviewerScore.objects.raw(sql, [user.id]))
        cache.set(key, val, None)
        return val
Exemplo n.º 6
0
    def get_performance_since(cls, user, since):
        """
        Returns sum of reviewer points since the given datetime.
        """
        key = cls.get_key('get_performance:%s:%s' % (user.id, since.isoformat()))
        val = cache.get(key)
        if val is not None:
            return val

        sql = """
             SELECT `reviewer_scores`.*,
                    SUM(`reviewer_scores`.`score`) AS `total`
             FROM `reviewer_scores`
             LEFT JOIN `addons` ON (`reviewer_scores`.`addon_id`=`addons`.`id`)
             WHERE `reviewer_scores`.`user_id` = %s AND
                   `reviewer_scores`.`created` >= %s
             ORDER BY `total` DESC
        """
        with skip_cache():
            val = list(ReviewerScore.objects.raw(sql, [user.id, since]))
        cache.set(key, val, 3600)
        return val
Exemplo n.º 7
0
    def get_performance_since(cls, user, since):
        """
        Returns sum of reviewer points since the given datetime.
        """
        key = cls.get_key('get_performance:%s:%s' %
                          (user.id, since.isoformat()))
        val = cache.get(key)
        if val is not None:
            return val

        sql = """
             SELECT `reviewer_scores`.*,
                    SUM(`reviewer_scores`.`score`) AS `total`
             FROM `reviewer_scores`
             LEFT JOIN `addons` ON (`reviewer_scores`.`addon_id`=`addons`.`id`)
             WHERE `reviewer_scores`.`user_id` = %s AND
                   `reviewer_scores`.`created` >= %s
             ORDER BY `total` DESC
        """
        with skip_cache():
            val = list(ReviewerScore.objects.raw(sql, [user.id, since]))
        cache.set(key, val, 3600)
        return val
Exemplo n.º 8
0
 def __call__(self, *args, **kw):
     with models.skip_cache():
         return self.f(*args, **kw)
Exemplo n.º 9
0
 def __call__(self, *args, **kw):
     with models.skip_cache():
         return self.f(*args, **kw)