mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-04-27 03:00:12 -04:00
Other discussions: only count public subreddits
This commit is contained in:
committed by
Neil Williams
parent
3b6dcc9f1f
commit
44a8dd6b1d
@@ -1241,7 +1241,8 @@ class LinkInfoPage(Reddit):
|
||||
# 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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user