Skip to content
This repository has been archived by the owner on Feb 24, 2020. It is now read-only.

Commit

Permalink
Finally worked out the bugs in active users. Fixes #40.
Browse files Browse the repository at this point in the history
  • Loading branch information
Paddy Foran committed Aug 18, 2011
1 parent efec709 commit 3870bb7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
15 changes: 11 additions & 4 deletions devlinks.py
Expand Up @@ -221,12 +221,19 @@ def post(self):
try:
user = models.getUser(record_value['user'], False)
except models.UserDoesNotExistError:
break
if user.last_seen.date() < timestamp.now().date():
user.updateLastSeen()
continue
last_seen = user.last_seen
new_last_seen = timestamp.now()
if datapoint.duration == "day":
last_seen = last_seen.replace(hour=0, minute=0, second=0,
microsecond=0)
new_last_seen = new_last_seen.replace(hour=0, minute=0,
second=0, microsecond=0)
if last_seen < new_last_seen:
user.updateLastSeen(new_last_seen)
user.save()
else:
break
continue
if datapoint.datapoint == 'quota':
datapoint.count = models.getQuota().amount
else:
Expand Down
7 changes: 5 additions & 2 deletions models.py
Expand Up @@ -26,8 +26,11 @@ class UserData(db.Model):
immunity = db.DateTimeProperty()
immunity_tokens = db.IntegerProperty()

def updateLastSeen(self):
self.last_seen = timestamp.now()
def updateLastSeen(self, newtimestamp=None):
if newtimestamp is None:
self.last_seen = timestamp.now()
else:
self.last_seen = newtimestamp

def save(self):
try:
Expand Down

0 comments on commit 3870bb7

Please sign in to comment.