def get_update_state(self, entity_id):
     row = models.UpdateState.objects.filter(session_id=self.session_id,
                                             entity_id=entity_id).first()
     if row:
         row.date = datetime.datetime.utcfromtimestamp(row.date)
         return updates.State(row.pts, row.qts, row.date, row.seq,
                              row.unread_count)
 def get_update_state(self, entity_id: int) -> Optional[updates.State]:
     row = self.UpdateState.query.get((self.session_id, entity_id))
     if row:
         date = datetime.datetime.utcfromtimestamp(row.date)
         return updates.State(row.pts, row.qts, date, row.seq,
                              row.unread_count)
     return None
Exemple #3
0
 def get_update_state(self, entity_id: int) -> Optional[updates.State]:
     t = self.UpdateState.__table__
     rows = self.engine.execute(
         select([t]).where(
             and_(t.c.session_id == self.session_id,
                  t.c.entity_id == entity_id)))
     try:
         _, _, pts, qts, date, seq, unread_count = next(rows)
         date = datetime.datetime.utcfromtimestamp(date)
         return updates.State(pts, qts, date, seq, unread_count)
     except StopIteration:
         return None
Exemple #4
0
 def get_update_state(self, entity_id):
     row = self._db_query(self.UpdateState).get(
         (self.session_id, self.entity_id))
     if row:
         return updates.State(row.pts, row.qts, row.date, row.seq,
                              row.unread_count)