Multireddit hot sort not limited to 24 hours.

This commit is contained in:
bsimpson63
2012-04-12 19:41:24 -07:00
committed by Neil Williams
parent 46dbdba1ac
commit ef951d4be5
3 changed files with 12 additions and 10 deletions

View File

@@ -324,7 +324,7 @@ class HotController(FixListing, ListingController):
return normalized_hot(sr_ids)
elif isinstance(c.site, MultiReddit):
return normalized_hot(c.site.kept_sr_ids)
return normalized_hot(c.site.kept_sr_ids, obey_age_limit=False)
#if not using the query_cache we still want cached front pages
elif (not g.use_query_cache

View File

@@ -31,12 +31,14 @@ from time import time
max_items = 150 # the number of links to request from the hot page
# query when the precomputer is disabled
cpdef list get_hot(list srs, only_fullnames = True):
cpdef list get_hot(list srs, only_fullnames=True, obey_age_limit=True):
"""Get the fullnames for the hottest normalised hottest links in a
subreddit. Use the query-cache to avoid some lookups if we
can."""
cdef double oldest
cdef int hot_page_age = g.HOT_PAGE_AGE
cdef int hot_page_age = 0
if obey_age_limit:
hot_page_age = g.HOT_PAGE_AGE
cdef int i
cdef double hot
cdef double thot # the top hotness on a given subreddit
@@ -109,8 +111,8 @@ cpdef _second(tuple x):
return x[2]
# memoized by our caller in normalized_hot.py
cpdef list normalized_hot_cached(sr_ids):
cpdef list normalized_hot_cached(sr_ids, obey_age_limit=True):
"""Fetches the hot lists for each subreddit, normalizes the
scores, and interleaves the results."""
srs = Subreddit._byID(sr_ids, return_dict = False)
return get_hot(srs, True)
srs = Subreddit._byID(sr_ids, return_dict=False)
return get_hot(srs, True, obey_age_limit)

View File

@@ -6,8 +6,8 @@ from r2.lib import _normalized_hot
from r2.lib._normalized_hot import get_hot # pull this into our namespace
@memoize('normalize_hot', time = g.page_cache_time)
def normalized_hot_cached(sr_ids):
return _normalized_hot.normalized_hot_cached(sr_ids)
def normalized_hot_cached(sr_ids, obey_age_limit=True):
return _normalized_hot.normalized_hot_cached(sr_ids, obey_age_limit)
def l(li):
if isinstance(li, list):
@@ -15,6 +15,6 @@ def l(li):
else:
return list(li)
def normalized_hot(sr_ids):
def normalized_hot(sr_ids, obey_age_limit=True):
sr_ids = l(sorted(sr_ids))
return normalized_hot_cached(sr_ids) if sr_ids else ()
return normalized_hot_cached(sr_ids, obey_age_limit) if sr_ids else ()