From 4e620f96b5e59733c94ebb3fc9140ad1634d4243 Mon Sep 17 00:00:00 2001 From: Neil Williams Date: Sat, 1 Dec 2012 16:19:16 -0800 Subject: [PATCH] Start writing comment participation by thread. This new DenormalizedRelation tracks when a user is the author of a comment in the given thread. Once it's backfilled, we can use it to quickly determine eligibility for the CommentPane cache. --- r2/r2/models/link.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/r2/r2/models/link.py b/r2/r2/models/link.py index afefeca34..fc3ba9441 100755 --- a/r2/r2/models/link.py +++ b/r2/r2/models/link.py @@ -735,6 +735,8 @@ class Comment(Thing, Printable): c._commit() + CommentParticipationByAccount.register(author, link) + changed(link, True) # link's number of comments changed inbox_rel = None @@ -1382,6 +1384,20 @@ class SaveHide(Relation(Account, Link)): pass class Click(Relation(Account, Link)): pass +class CommentParticipationByAccount(tdb_cassandra.DenormalizedRelation): + _use_db = True + _last_modified_name = 'Commented' + _write_last_modified = False + _views = [] + + @classmethod + def value_for(cls, thing1, thing2, opaque): + return '' + + @classmethod + def register(cls, user, link): + cls.create(user, [link]) + class GildedCommentsByAccount(tdb_cassandra.DenormalizedRelation): _use_db = True