Clean out dead last-modified rel code.

This commit is contained in:
Neil Williams
2012-06-11 13:31:17 -07:00
parent aeb0d3bb7a
commit 2243af7306
6 changed files with 1 additions and 57 deletions

View File

@@ -768,8 +768,6 @@ def new_vote(vote, foreground=False):
results.append(get_domain_links(domain, sort, "all"))
add_queries(results, insert_items = item, foreground=foreground)
vote._fast_query_timestamp_touch(user)
if isinstance(item, Link):
# must update both because we don't know if it's a changed

View File

@@ -778,30 +778,6 @@ def Relation(type1, type2, denorm1 = None, denorm2 = None):
#know it's deleted. save -> unsave, hide -> unhide
self._name = 'un' + self._name
@classmethod
def _fast_query_timestamp_touch(cls, thing1):
thing_utils.set_last_modified_for_cls(thing1, cls._type_name)
@classmethod
def _can_skip_lookup(cls, thing1, thing2):
# we can't possibly have voted on things that were created
# after the last time we voted. for relations that have an
# invariant like this we can avoid doing these lookups as
# long as the relation takes responsibility for keeping
# the timestamp up-to-date
last_done = thing_utils.get_last_modified_for_cls(
thing1, cls._type_name)
if not last_done:
return False
if thing2._date > last_done:
return True
return False
@classmethod
def _fast_query(cls, thing1s, thing2s, name, data=True, eager_load=True,
thing_data=False, timestamp_optimize = False):
@@ -830,9 +806,6 @@ def Relation(type1, type2, denorm1 = None, denorm2 = None):
t2_ids = set()
names = set()
for t1, t2, name in pairs:
if timestamp_optimize and cls._can_skip_lookup(thing1_dict[t1],
thing2_dict[t2]):
continue
t1_ids.add(t1)
t2_ids.add(t2)
names.add(name)

View File

@@ -28,21 +28,6 @@ def set_last_modified(thing, action):
key = last_modified_key(thing, action)
g.permacache.set(key, make_last_modified())
def set_last_modified_for_cls(user, cls_type_name):
if cls_type_name != "vote_account_link":
set_last_modified(user, "cls_" + cls_type_name)
def get_last_modified_for_cls(user, cls_type_name):
# vote times are already stored in the permacache and updated by the
# query queue
if cls_type_name == "vote_account_link":
return max(last_modified_date(user, "liked"),
last_modified_date(user, "disliked"))
# other types are not -- special key for them
elif cls_type_name in ("vote_account_comment", "savehide"):
return last_modified_date(user, "cls_" + cls_type_name)
def last_modified_multi(things, action):
from pylons import g
cache = g.permacache
@@ -52,12 +37,3 @@ def last_modified_multi(things, action):
last_modified = cache.get_multi(keys.keys())
return dict((keys[k], v) for k, v in last_modified.iteritems())
def set_last_visit(thing):
from pylons import g
from r2.lib.cache import CL_ONE
key = last_modified_key(thing, "visit")
g.permacache.set(key, make_last_modified())

View File

@@ -24,7 +24,7 @@ from r2.lib.db.operators import lower
from r2.lib.db.userrel import UserRel
from r2.lib.memoize import memoize
from r2.lib.utils import modhash, valid_hash, randstr, timefromnow
from r2.lib.utils import UrlParser, set_last_visit
from r2.lib.utils import UrlParser
from r2.lib.utils import constant_time_compare
from r2.lib.cache import sgm
from r2.lib import filters

View File

@@ -146,7 +146,6 @@ class Link(Thing, Printable):
except CreationError, e:
return somethinged(user, self)[(user, self, name)]
rel._fast_query_timestamp_touch(user)
return saved
def _unsomething(self, user, somethinged, name):

View File

@@ -215,8 +215,6 @@ class Vote(MultiRelation('vote',
v._commit()
v._fast_query_timestamp_touch(sub)
up_change, down_change = score_changes(amount, oldamount)
if not (is_new and obj.author_id == sub._id and amount == 1):