Esempio n. 1
0
    def get_unread_count(self, instance, read_at, action=None, target=None):
        if read_at:
            read_at = to_timestamp(read_at)

        key = self._make_key(instance, 'private', action=action, target=target)

        return self.client.zcount(key, read_at, to_timestamp(datetime.now()))
Esempio n. 2
0
    def get_unread_count(self, action=None, target=None):
        read_at = self.read_at or 0

        if read_at:
            read_at = to_timestamp(read_at)

        key = self._make_key('private', action=action, target=target)

        return self.client.zcount(key, read_at, to_timestamp(datetime.now()))
Esempio n. 3
0
    def _save(self, action):
        result = {
            'actor': app.backend.get_uid(action.actor),
            'verb': action.verb,
        }

        timestamp = to_timestamp(action.date)

        result['timestamp'] = timestamp

        if action.target:
            result['target'] = app.backend.get_uid(action.target)

        uid = self.storage.make_uid(result)

        action.uid = uid
        action.timestamp = timestamp
Esempio n. 4
0
    def mark_as_read(self, timestamp=None):
        if timestamp is None:
            timestamp = datetime.now()

        self.client.set(self._get_read_key(), to_timestamp(timestamp))
Esempio n. 5
0
 def timestamp(self):
     return to_timestamp(self.date)
Esempio n. 6
0
    def mark_as_read(self, timestamp=None):
        if timestamp is None:
            timestamp = datetime.now()

        self.client.set(self._get_read_key(), to_timestamp(timestamp))
Esempio n. 7
0
 def timestamp(self):
     return to_timestamp(self.date)
Esempio n. 8
0
 def mark_as_read(self, instance, timestamp):
     self.client.set(self.get_read_key(instance), to_timestamp(timestamp))