本文整理汇总了Python中models.Notification.query方法的典型用法代码示例。如果您正苦于以下问题:Python Notification.query方法的具体用法?Python Notification.query怎么用?Python Notification.query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Notification
的用法示例。
在下文中一共展示了Notification.query方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getUsersRecentlyNotified
# 需要导入模块: from models import Notification [as 别名]
# 或者: from models.Notification import query [as 别名]
def getUsersRecentlyNotified(self):
"Return list of Users notified in the last 24 hours."
now = datetime.datetime.now()
yesterday = now - datetime.timedelta(days=1)
lastDaysNotes = Notification.query(
Notification.createdTime > yesterday).fetch()
for note in lastDaysNotes:
self.restoreTransients(note)
return [note.user for note in lastDaysNotes]
示例2:
# 需要导入模块: from models import Notification [as 别名]
# 或者: from models.Notification import query [as 别名]
import datetime
from models import Notification
import logging
curTime = datetime.datetime.now() + datetime.timedelta(hours=5, minutes=30)
weekBefore = curTime - datetime.timedelta(days=7)
logging.basicConfig(level=logging.DEBUG)
LOG = logging.getLogger(__name__)
LOG.info('Deleting 1 week old notifications')
result = notifications = Notification.query(Notification.timeStamp < weekBefore).fetch()
for notification in result:
notification.key.delete()
示例3: str
# 需要导入模块: from models import Notification [as 别名]
# 或者: from models.Notification import query [as 别名]
import datetime
from models import Notification
from FCM import sendNotificationSingle
from google.appengine.api import memcache
from google.appengine.ext import ndb
curTime = datetime.datetime.now()
prevTime = curTime - datetime.timedelta(hours=1)
results = Notification.query(ndb.AND((Notification.timeStamp <= curTime),
(Notification.timeStamp >= prevTime)))
profileIds = {}
for notification in results:
for profileId in notification.profileIdList:
if profileId in profileIds:
profileIds[profileId] += 1
else:
profileIds[profileId] = 0
for profileId in profileIds:
count = profileIds[profileId]
if count == 0:
continue
fcmId = memcache.get('fcm' + profileId.urlsafe())
if fcmId is None:
profile = profileId.get()
if profile is None:
continue
fcmId = profile.gcmId
memcache.add('fcm' + profileId.urlsafe(), fcmId, 3600)
text = 'You have ' + str(count) + ' new notifications'