diff --git a/r2/r2/models/account.py b/r2/r2/models/account.py index 5d97fe066..b7b3566be 100644 --- a/r2/r2/models/account.py +++ b/r2/r2/models/account.py @@ -259,19 +259,23 @@ class Account(Thing): def update_last_visit(self, current_time): from admintools import apply_updates - apply_updates(self) + timer = g.stats.get_timer("account.update_last_visit") + timer.start() + + apply_updates(self, timer) prev_visit = LastModified.get(self._fullname, "Visit") - if prev_visit and current_time - prev_visit < timedelta(days=1): - return + timer.intermediate("get_last_modified") - g.log.debug ("Updating last visit for %s from %s to %s" % - (self.name, prev_visit, current_time)) + if prev_visit and current_time - prev_visit < timedelta(days=1): + timer.stop() + return LastModified.touch(self._fullname, "Visit") self.last_visit = int(time.time()) self._commit() + timer.stop("set_last_modified") def make_cookie(self, timestr=None): if not self._loaded: diff --git a/r2/r2/models/admintools.py b/r2/r2/models/admintools.py index 1f89f57c8..7461855fa 100644 --- a/r2/r2/models/admintools.py +++ b/r2/r2/models/admintools.py @@ -329,7 +329,7 @@ def valid_thing(v, karma, *a, **kw): def valid_user(v, sr, karma, *a, **kw): return True -def apply_updates(user): +def apply_updates(user, timer): pass def update_score(obj, up_change, down_change, vote, old_valid_thing):