'Select a random subset from sr_ids.
Used for limiting the number of subscribed subreddits shown on a user\'s
front page. Selection is cached for a while so the front page doesn\'t
jump around.'

@classmethod
def random_reddits(cls, user_name, sr_ids, limit):

    if (not limit):
        return sr_ids
    if g.automatic_reddits:
        automatics = Subreddit._by_name(g.automatic_reddits, stale=True).values()
        automatic_ids = [sr._id for sr in automatics if (sr._id in sr_ids)]
        sr_ids = [sr_id for sr_id in sr_ids if (sr_id not in automatic_ids)]
    else:
        automatic_ids = []
    if (len(sr_ids) > limit):
        sr_ids = sorted(sr_ids)
        sr_ids = cls.random_reddits_cached(user_name, sr_ids, limit)
    return (sr_ids + automatic_ids)
