Account.update_last_visit: Add timer.

This commit is contained in:
Brian Simpson
2015-09-26 10:50:50 -04:00
parent c902b60293
commit a7c74d7c3d
2 changed files with 10 additions and 6 deletions

View File

@@ -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:

View File

@@ -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):