From ff7f332993d543e66c76c2f1fca9333caf697b57 Mon Sep 17 00:00:00 2001 From: Neil Williams Date: Thu, 24 May 2012 19:45:42 -0700 Subject: [PATCH] Touch LastModified on tdb_cassandra.Relation._commit. --- r2/r2/lib/db/tdb_cassandra.py | 8 +++++++- r2/r2/lib/db/thing.py | 6 +++++- r2/r2/models/link.py | 7 +++++-- r2/r2/models/vote.py | 4 ---- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/r2/r2/lib/db/tdb_cassandra.py b/r2/r2/lib/db/tdb_cassandra.py index 4789f80e9..7287e3cde 100644 --- a/r2/r2/lib/db/tdb_cassandra.py +++ b/r2/r2/lib/db/tdb_cassandra.py @@ -877,7 +877,13 @@ class Relation(ThingBase): def _commit(self, *a, **kw): assert self._id == self._rowkey(self.thing1_id, self.thing2_id) - return ThingBase._commit(self, *a, **kw) + retval = ThingBase._commit(self, *a, **kw) + + from r2.models.last_modified import LastModified + fullname = self._thing1_cls._fullname_from_id36(self.thing1_id) + LastModified.touch(fullname, self._cf.column_family) + + return retval @classmethod def _rel(cls, thing1_cls, thing2_cls): diff --git a/r2/r2/lib/db/thing.py b/r2/r2/lib/db/thing.py index 114190e4c..a32d14186 100644 --- a/r2/r2/lib/db/thing.py +++ b/r2/r2/lib/db/thing.py @@ -342,9 +342,13 @@ class DataThing(object): def _id36(self): return to36(self._id) + @classmethod + def _fullname_from_id36(cls, id36): + return cls._type_prefix + to36(cls._type_id) + '_' + id36 + @property def _fullname(self): - return self._type_prefix + to36(self._type_id) + '_' + to36(self._id) + return self._fullname_from_id36(self._id36) #TODO error when something isn't found? @classmethod diff --git a/r2/r2/models/link.py b/r2/r2/models/link.py index cf7063f81..e02c48250 100755 --- a/r2/r2/models/link.py +++ b/r2/r2/models/link.py @@ -1228,8 +1228,8 @@ class CassandraSave(SimpleRelation): _cf_name = 'Save' _connection_pool = 'main' - # thing1_cls = Account - # thing2_cls = Link + _thing1_cls = Account + _thing2_cls = Link @classmethod def _save(cls, *a, **kw): @@ -1262,6 +1262,9 @@ class CassandraHide(SimpleRelation): _ttl = 7*24*60*60 _connection_pool = 'main' + _thing1_cls = Account + _thing2_cls = Link + @classmethod def _hide(cls, *a, **kw): return cls._create(*a, **kw) diff --git a/r2/r2/models/vote.py b/r2/r2/models/vote.py index 02e455bfe..36f5f925d 100644 --- a/r2/r2/models/vote.py +++ b/r2/r2/models/vote.py @@ -136,8 +136,6 @@ class CassandraLinkVote(CassandraVote): _cf_name = 'LinkVote' _read_consistency_level = tdb_cassandra.CL.ONE - # these parameters aren't actually meaningful, they just help - # keep track # _views = [VotesByLink, VotesByDay] _thing1_cls = Account _thing2_cls = Link @@ -161,8 +159,6 @@ class CassandraCommentVote(CassandraVote): _cf_name = 'CommentVote' _read_consistency_level = tdb_cassandra.CL.ONE - # these parameters aren't actually meaningful, they just help - # keep track _thing1_cls = Account _thing2_cls = Comment