From 36191d3ac99cf3e5f653074fc497dcdf0ba1110d Mon Sep 17 00:00:00 2001 From: Jason Harvey Date: Thu, 27 Dec 2012 02:57:00 -0800 Subject: [PATCH] Add CommentsByAccount and LinksByAccount. --- r2/r2/models/link.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/r2/r2/models/link.py b/r2/r2/models/link.py index c9073772e..891a1e936 100755 --- a/r2/r2/models/link.py +++ b/r2/r2/models/link.py @@ -152,6 +152,7 @@ class Link(Thing, Printable): comment_tree_version=cls._choose_comment_tree_version()) l._commit() l.set_url_cache() + LinksByAccount.add_link(author, l) if author._spam: g.stats.simple_event('spam.autoremove.link') admintools.spam(l, banner='banned user') @@ -738,6 +739,8 @@ class Comment(Thing, Printable): changed(link, True) # link's number of comments changed + CommentsByAccount.add_comment(author, c) + inbox_rel = None # only global admins can be message spammed. # Don't send the message if the recipient has blocked @@ -1707,3 +1710,30 @@ class ModeratorInbox(Relation(Subreddit, Message)): i._commit() res.append(i) return res + +class CommentsByAccount(tdb_cassandra.DenormalizedRelation): + _use_db = True + _write_last_modified = False + _views = [] + + @classmethod + def value_for(cls, thing1, thing2, opaque): + return '' + + @classmethod + def add_comment(cls, account, comment): + cls.create(account, [comment]) + + +class LinksByAccount(tdb_cassandra.DenormalizedRelation): + _use_db = True + _write_last_modified = False + _views = [] + + @classmethod + def value_for(cls, thing1, thing2, opaque): + return '' + + @classmethod + def add_link(cls, account, link): + cls.create(account, [link])