Exemple #1
0
 def lru(self, index):
     result = CollectedDatum.query(
         CollectedDatum.value,
         func.max(CollectedDatum.created_at).label('latest')).filter_by(
             key=self.key,
             user_id=g.user.id).group_by(CollectedDatum.value).order_by(
                 desc('latest')).offset(index).limit(1).first()
     return result[0] if result else self.fallback_value
Exemple #2
0
 def __init__(self, key):
     self.key = key
     self.fallback_value = ''
     self.query = CollectedDatum.query(CollectedDatum.value,
                                       CollectedDatum.created_at).filter_by(
                                           key=key, user_id=g.user.id)