mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-01-27 07:48:16 -05:00
update the choosing of the reddits to fix the empty-next-page bug
This commit is contained in:
@@ -224,8 +224,7 @@ class HotController(FixListing, ListingController):
|
||||
self.fix_listing = False
|
||||
|
||||
if c.site == Default:
|
||||
sr_ids = Subreddit.user_subreddits(c.user,
|
||||
limit = g.num_default_reddits)
|
||||
sr_ids = Subreddit.user_subreddits(c.user)
|
||||
return normalized_hot(sr_ids)
|
||||
#if not using the query_cache we still want cached front pages
|
||||
elif (not g.use_query_cache
|
||||
|
||||
@@ -323,6 +323,14 @@ class Subreddit(Thing, Printable):
|
||||
srs = cls.top_lang_srs(c.content_langs, limit)
|
||||
return [s._id for s in srs] if ids else srs
|
||||
|
||||
@classmethod
|
||||
@memoize('random_reddits', time = 1800)
|
||||
def random_reddits(cls, user_name, sr_ids, limit):
|
||||
"""This gets called when a user is subscribed to more than 50
|
||||
reddits. Randomly choose 50 of those reddits and cache it for
|
||||
a while so their front page doesn't jump around."""
|
||||
return random.sample(sr_ids, limit)
|
||||
|
||||
@classmethod
|
||||
def user_subreddits(cls, user, ids = True, limit = sr_limit):
|
||||
"""
|
||||
@@ -336,7 +344,8 @@ class Subreddit(Thing, Printable):
|
||||
if user and user.has_subscribed:
|
||||
sr_ids = Subreddit.reverse_subscriber_ids(user)
|
||||
if limit and len(sr_ids) > limit:
|
||||
sr_ids = random.sample(sr_ids, limit)
|
||||
sr_ids.sort()
|
||||
sr_ids = cls.random_reddits(user.name, sr_ids, limit)
|
||||
return sr_ids if ids else Subreddit._byID(sr_ids, True, False)
|
||||
else:
|
||||
# if there is a limit, we want *at most* limit subreddits.
|
||||
|
||||
Reference in New Issue
Block a user