Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use query cache to get preview comments for subreddit CSS.

  • Loading branch information...
commit b279d29ee28b529d78b3daf68269588edbfad315 1 parent 0f7e3a6
@spladug spladug authored
Showing with 15 additions and 5 deletions.
  1. +15 −5 r2/r2/lib/cssfilter.py
View
20 r2/r2/lib/cssfilter.py
@@ -364,13 +364,23 @@ def validate_css(string):
return parsed,report
def find_preview_comments(sr):
- comments = Comment._query(Comment.c.sr_id == c.site._id,
- limit=25, data=True)
- comments = list(comments)
- if not comments:
- comments = Comment._query(limit=25, data=True)
+ if g.use_query_cache:
+ from r2.lib.db.queries import get_sr_comments, get_all_comments
+
+ comments = get_sr_comments(c.site)
comments = list(comments)
+ if not comments:
+ comments = get_all_comments()
+ comments = list(comments)
+ return Thing._by_fullname(comments[:25], data=True, return_dict=False)
+ else:
+ comments = Comment._query(Comment.c.sr_id == c.site._id,
+ limit=25, data=True)
+ comments = list(comments)
+ if not comments:
+ comments = Comment._query(limit=25, data=True)
+ comments = list(comments)
return comments
def find_preview_links(sr):
Please sign in to comment.
Something went wrong with that request. Please try again.