mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-01-21 04:48:08 -05:00
Read from CommentVisitsByUser and stop writing hardcache.
This commit is contained in:
@@ -189,32 +189,6 @@ class FrontController(RedditController):
|
||||
abort(403, 'forbidden')
|
||||
return self.abort404()
|
||||
|
||||
def _get_comment_visits(self, article, user, new_visit):
|
||||
timer = g.stats.get_timer("gold.comment_visits")
|
||||
timer.start()
|
||||
|
||||
hc_key = "comment_visits-%s-%s" % (user.name, article._id36)
|
||||
old_visits = g.hardcache.get(hc_key, [])
|
||||
|
||||
if old_visits:
|
||||
last_visit = max(old_visits)
|
||||
time_since_last = new_visit - last_visit
|
||||
if time_since_last.seconds <= g.comment_visits_period:
|
||||
# they were here recently; consider that the same visit as now
|
||||
old_visits.pop()
|
||||
timer.stop()
|
||||
return old_visits
|
||||
|
||||
copy = list(old_visits)
|
||||
copy.append(new_visit)
|
||||
if len(copy) > 10:
|
||||
copy.pop(0)
|
||||
g.hardcache.set(hc_key, copy, 86400 * 2)
|
||||
timer.stop()
|
||||
CommentVisitsByUser.add_visit(user, article, new_visit)
|
||||
return old_visits
|
||||
|
||||
|
||||
@csrf_exempt
|
||||
@validate(article=VLink('article'),
|
||||
comment=VCommentID('comment'),
|
||||
@@ -285,8 +259,11 @@ class FrontController(RedditController):
|
||||
elif (c.user_is_loggedin and
|
||||
(c.user.gold or sr.is_moderator(c.user)) and
|
||||
c.user.pref_highlight_new_comments):
|
||||
previous_visits = self._get_comment_visits(
|
||||
article, c.user, c.start_time)
|
||||
timer = g.stats.get_timer("gold.comment_visits")
|
||||
timer.start()
|
||||
previous_visits = CommentVisitsByUser.get_and_update(
|
||||
c.user, article, c.start_time)
|
||||
timer.stop()
|
||||
|
||||
# check if we just came from the submit page
|
||||
infotext = None
|
||||
|
||||
Reference in New Issue
Block a user