Browse files

Other discussions: only count public subreddits

  • Loading branch information...
1 parent 3b6dcc9 commit 44a8dd6b1d54d2b3296a73e50bf7c17cbde00586 @Deimos Deimos committed with spladug Feb 13, 2014
Showing with 10 additions and 3 deletions.
  1. +2 −1 r2/r2/lib/pages/pages.py
  2. +8 −2 r2/r2/lib/utils/utils.py
View
3 r2/r2/lib/pages/pages.py
@@ -1241,7 +1241,8 @@ def __init__(self, link = None, comment = None,
# avoid doing this lookup twice
if num_duplicates is None:
builder = url_links_builder(self.link.url,
- exclude=self.link._fullname)
+ exclude=self.link._fullname,
+ public_srs_only=True)
self.num_duplicates = len(builder.get_items()[0])
else:
self.num_duplicates = num_duplicates
View
10 r2/r2/lib/utils/utils.py
@@ -922,9 +922,9 @@ def common_subdomain(domain1, domain2):
def url_links_builder(url, exclude=None, num=None, after=None, reverse=None,
- count=None):
+ count=None, public_srs_only=False):
from r2.lib.template_helpers import add_sr
- from r2.models import IDBuilder, Link, NotFound
+ from r2.models import IDBuilder, Link, NotFound, Subreddit
from operator import attrgetter
if url.startswith('/'):
@@ -937,6 +937,12 @@ def url_links_builder(url, exclude=None, num=None, after=None, reverse=None,
links = [ link for link in links
if link._fullname != exclude ]
+
+ if public_srs_only and not c.user_is_admin:
+ subreddits = Subreddit._byID([link.sr_id for link in links], data=True)
+ links = [link for link in links
+ if subreddits[link.sr_id].type != "private"]
+
links.sort(key=attrgetter('num_comments'), reverse=True)
# don't show removed links in duplicates unless admin or mod

0 comments on commit 44a8dd6

Please sign in to comment.