Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Track user last visit time and account creation

  • Loading branch information...
commit d32256c2964c1bd25ffba6289a29a112c21e3529 1 parent b0cb744
@metzen metzen authored
Showing with 6 additions and 1 deletion.
  1. +4 −1 server/main.py
  2. +2 −0  server/models.py
View
5 server/main.py
@@ -1,6 +1,7 @@
"""Main request handlers."""
import collections
+import datetime
import json
import logging
@@ -8,6 +9,7 @@
from google.appengine.api import oauth
from google.appengine.api import users
from google.appengine.api import xmpp
+from google.appengine.ext import db
import webapp2
import models
@@ -58,8 +60,9 @@ def __init__(self, request, response):
memcache.set(key, self.user)
if self.user.email != user.email():
self.user.email = user.email()
- self.user.put()
memcache.set(key, self.user)
+ self.user.last_visit_at = datetime.datetime.now()
+ db.put_async(self.user)
def dispatch(self):
if not self.user and self.request.method != 'OPTIONS':
View
2  server/models.py
@@ -7,6 +7,8 @@
class User(db.Model):
# key: User.user_id()
email = db.StringProperty()
+ created_at = db.DateTimeProperty(auto_now_add=True)
+ last_visit_at = db.DateTimeProperty()
@classmethod
def get_memcache_key(cls, user_id):
Please sign in to comment.
Something went wrong with that request. Please try again.