示例#1
0
 def unread_notification(self):
     from models.notification import Notification
     return [
         notifications for notifications in
         Notification.select().where((Notification.recipient_id == self.id)
                                     & (Notification.read == False))
     ]
示例#2
0
 def sorted_notification(self):
     from models.notification import Notification
     return [
         notifications for notifications in Notification.select().where((
             Notification.recipient_id == self.id
         )).order_by(Notification.id.desc()).limit(5)
     ]
示例#3
0
    async def get(self, user: UserProfile) -> str:

        try:
            query = await self.application.objects.execute(
                Notification.select().where(
                    Notification.target == user).order_by(
                        Notification.created_at.desc()).limit(100))
            if query:
                self.write(
                    json.dumps([x.to_json() for x in query], default=str))
            else:
                self.write([])
        except Exception as e:
            log.error(str(e))