def recordEvent(cls, userKeyUrlsafe, entityKey1Urlsafe, entityKey2Urlsafe, eventName): logging.info('Entered RECORD event') userKey = ndb.Key(urlsafe=userKeyUrlsafe) entityKey1 = None entityKey2 = None if entityKey1Urlsafe and entityKey1Urlsafe != '': entityKey1 = ndb.Key(urlsafe=entityKey1Urlsafe) if entityKey2Urlsafe and entityKey2Urlsafe != '': logging.info('E2US: ++++++ ' + str(entityKey2Urlsafe)) entityKey2 = ndb.Key(urlsafe=entityKey2Urlsafe) todayPST = PST.convert(datetime.datetime.now()) dayGMT = datetime.date(todayPST.year, todayPST.month, todayPST.day) qry = DayEventSummary.query(DayEventSummary.day == dayGMT, DayEventSummary.name == eventName) daySummaries = qry.fetch(1) daySummary = None if daySummaries: daySummary = daySummaries[0] if daySummary: daySummary.count = daySummary.count + 1 else: daySummary = DayEventSummary(day=dayGMT, name=eventName) daySummary.put() r = ReportEvent(user=userKey, refEntity1=entityKey1, refEntity2=entityKey2, time=datetime.datetime.now(), name=eventName) r.put()
def recordEvent(cls, userKeyUrlsafe, entityKey1Urlsafe, entityKey2Urlsafe, eventName): logging.info('Entered RECORD event') userKey = ndb.Key(urlsafe = userKeyUrlsafe) entityKey1 = None entityKey2 = None if entityKey1Urlsafe and entityKey1Urlsafe != '': entityKey1 = ndb.Key(urlsafe = entityKey1Urlsafe) if entityKey2Urlsafe and entityKey2Urlsafe != '': logging.info('E2US: ++++++ ' + str(entityKey2Urlsafe)) entityKey2 = ndb.Key(urlsafe = entityKey2Urlsafe) todayPST = PST.convert(datetime.datetime.now()) dayGMT = datetime.date(todayPST.year, todayPST.month, todayPST.day) qry = DayEventSummary.query( DayEventSummary.day == dayGMT, DayEventSummary.name == eventName ) daySummaries = qry.fetch(1) daySummary = None if daySummaries: daySummary = daySummaries[0] if daySummary: daySummary.count = daySummary.count + 1 else: daySummary = DayEventSummary( day=dayGMT, name=eventName) daySummary.put() r = ReportEvent(user=userKey, refEntity1=entityKey1, refEntity2=entityKey2, time = datetime.datetime.now(), name = eventName) r.put()
def PSTupdated(self): return PST.convert(self.updated)
def PSTlastView(self): return PST.convert(self.lastViewed)
def PSTlastlogin(self): return PST.convert(self.lastLogin)
def PSTdateEdited(self): return PST.convert(self.dateEdited)