Exemplo n.º 1
0
    def get_last_granular_timestamp(self, **kwargs):
        def get_timestamp(row):
            if row:
                return row.timestamp
            return None

        return GranularData.find(
            where=['uuid=? AND method=?',
                kwargs['authorization'].uuid,
                kwargs['method'],
            ],
            limit=1,
            orderby='timestamp DESC',
        ).addCallback(get_timestamp)
Exemplo n.º 2
0
    def find_unwritten_granular_data(self, data, **kwargs):
        def filterme(db_data):
            ret = []
            for datum, exists in zip(data, db_data):
                if not exists:
                    ret.append(datum)
            return ret

        uuid = kwargs['authorization'].uuid
        return defer.gatherResults([
            GranularData.exists(
                where=['uuid=? AND method=? AND item_id=?',
                    uuid,
                    kwargs['method'],
                    datum['id'],
                ],
            ) for datum in data
        ]).addCallback(filterme)
Exemplo n.º 3
0
    def delete_user_data(self, **kwargs):
        "Delete all the user-data"
        # We might get a UUID or a client_name/service_name/user_id tuple.
        uuid = kwargs.get('uuid')
        if not uuid:
            assert kwargs.get('client_name') != None
            assert kwargs.get('service_name') != None
            assert kwargs.get('user_id') != None

            authz = yield Authz.find(where=self.args_to_where(**kwargs), limit=1)
            if authz:
                uuid = authz.uuid
            else:
                defer.returnValue(False)

        yield UserData.deleteAll(where=['uuid = ?', uuid])
        yield GranularData.deleteAll(where=['uuid = ?', uuid])
        yield StreamCache.deleteAll(where=['uuid = ?', uuid])
        defer.returnValue(True)