当前位置: 首页>>代码示例>>Python>>正文


Python Notification.query方法代码示例

本文整理汇总了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]
开发者ID:rastaehli,项目名称:wordwars,代码行数:11,代码来源:repositories.py

示例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()
开发者ID:Flap-Py,项目名称:NotesCC,代码行数:15,代码来源:deleteNotification.py

示例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'
开发者ID:Flap-Py,项目名称:NotesCC,代码行数:33,代码来源:sendNotification.py


注:本文中的models.Notification.query方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。