def find_update(cls, time_since_update=AlertConstants.ALERT_TIMEOUT):
     # update alerts status if last update was more than ALERT_TIMEOUT minutes ago,
     # default 10 minutes
     last_updated_limit = datetime.datetime.utcnow() - datetime.timedelta(
         minutes=time_since_update)
     return [
         cls(**element)
         for element in Database.find(AlertConstants.COLLECTION, {
             "last_checked": {
                 "$lte": last_updated_limit
             },
             "active": True
         })
     ]
Exemple #2
0
 def all(cls):
     return [
         cls(**element)
         for element in Database.find(StoreConstants.COLLECTION, ({}))
     ]
Exemple #3
0
 def from_blog(id):
     return [
         post for post in Database.find(collection='posts',
                                        query={'blog_id': id})
     ]
 def find_by_user_email(cls, user_email):
     return [
         cls(**elem) for elem in Database.find(AlertConstants.COLLECTION,
                                               {'user_email': user_email})
     ]