Dirty cache when rating
This commit is contained in:
parent
913ec45acf
commit
fae8422508
2 changed files with 12 additions and 0 deletions
|
@ -83,8 +83,17 @@ def cache_wrapper(prefix, timeout=None):
|
|||
if result is not None:
|
||||
_set_l0(key, result)
|
||||
|
||||
def dirty_multi(args_list):
|
||||
keys = []
|
||||
for args in args_list:
|
||||
keys.append(get_key(func, *args))
|
||||
cache.delete_many(keys)
|
||||
if l0_cache:
|
||||
l0_cache.delete_many(keys)
|
||||
|
||||
wrapper.dirty = dirty
|
||||
wrapper.prefetch_multi = prefetch_multi
|
||||
wrapper.dirty_multi = dirty_multi
|
||||
|
||||
return wrapper
|
||||
|
||||
|
|
|
@ -146,6 +146,7 @@ def recalculate_ratings(ranking, old_mean, times_ranked, historical_p):
|
|||
|
||||
def rate_contest(contest):
|
||||
from judge.models import Rating, Profile
|
||||
from judge.models.profile import _get_basic_info
|
||||
|
||||
rating_subquery = Rating.objects.filter(user=OuterRef("user"))
|
||||
rating_sorted = rating_subquery.order_by("-contest__end_time")
|
||||
|
@ -237,6 +238,8 @@ def rate_contest(contest):
|
|||
)
|
||||
)
|
||||
|
||||
_get_basic_info.dirty_multi([(uid,) for uid in user_ids])
|
||||
|
||||
|
||||
RATING_LEVELS = [
|
||||
"Newbie",
|
||||
|
|
Loading…
Reference in a new issue