def getRoomsByUser(cls, user): """ Will return the chat rooms created by the requested user """ userID = str(user['id']) index = IndexByUser().get() if not index.has_key(userID): return [] return index[userID]
def getNumberOfRoomsByUser(cls, user, exclude=None): """ Will return the number of rooms that the user has in this index, can exclude a conference if passed through by exclude param. """ userID = str(user['id']) index = IndexByUser().get() if not index.has_key(userID): return 0 idx = index[userID].values() if exclude is not None: idx = DBHelpers()._filterIndexExclusion(idx, exclude) return len(idx)
def getNumberOfRoomsByUser(cls, user, exclude=None): """ Will return the number of rooms that the user has in this index, can exclude a conference if passed through by exclude param. """ userID = str(user['id']) index = IndexByUser().get() if not index.has_key(userID): return 0 idx = index[userID].values() if exclude is not None: idx = DBHelpers()._filterIndexExclusion(idx, exclude) return len(idx)
def getRoomsByUser(cls, user, offset=0, limit=None, exclude=None): """ Will return the chat rooms created by the requested user """ userID = str(user['id']) index = IndexByUser().get() if not index.has_key(userID): return [] idx = index[userID].values() if exclude is not None: idx = DBHelpers()._filterIndexExclusion(idx, exclude) if offset >= len(idx): # If we have gone over the boundaries return [] limit = limit if limit is not None else (len(index[userID]) - 1) limit += offset return list(idx[offset:limit])
def getRoomsByUser(cls, user, offset=0, limit=None, exclude=None): """ Will return the chat rooms created by the requested user """ userID = str(user['id']) index = IndexByUser().get() if not index.has_key(userID): return [] idx = index[userID].values() if exclude is not None: idx = DBHelpers()._filterIndexExclusion(idx, exclude) if offset >= len(idx): # If we have gone over the boundaries return [] limit = limit if limit is not None else (len(index[userID]) - 1) limit += offset return list(idx[offset:limit])