def delete_favourite(username, post_id): """ Removes the specified post from the user's set of favourites. """ if _is_user_created(username): post_id = str(post_id) db.srem(username + APPEND_KEY_FAVS, str(post_id)) return True else: return False
def delete_tag_user_tags(username, tag): """ Deletes a tag from the user's set of tags and from the posts the user has written. """ debug("DELETE TAG :" + tag + ", from:" + username) db.srem(username + APPEND_KEY_TAG, tag) _delete_tag_from_all_user_posts(username, tag)
def delete_tag_from_post(post_id, tag): """ Deletes a tag from the post's set of tags """ debug("DELETE TAG from post. tag:" + tag + ", post #:" + str(post_id)) if _is_post_created(post_id): db.srem(db.hget(post_id + APPEND_KEY_POSTS, KEY_TAGS) + APPEND_KEY_TAG, tag) # Decrement the score _inc_dec_tag(tag, False) # Delete from the sorted set of tag-name -- post-ids _remove_post_tag_name(post_id, tag)
def get_favourites(username): """ Returns a list of posts favourited by the given user. """ if _is_user_created(username): ret = [] to_delete = [] for post_id in db.smembers(username + APPEND_KEY_FAVS): post = get_post(post_id) if post == None: # Delete from the favourite set to_delete.append(post_id) else: ret.append(post) if len(to_delete) > 0: for item in to_delete: db.srem(username + APPEND_KEY_FAVS, item) return ret else: return None
def delete_sensor_from_node(node_id, sensor_id): """ Deletes a sensor from the node.""" db.srem(KEY_LIST_SENSORS_IN_NODE + str(node_id), str(sensor_id)) db.delete(KEY_SENSORS + str(sensor_id))
def sendNogrids(obj, func, **kwargs): for uid in db.smembers("nogrid"): if uid not in obj.clients: db.srem("nogrid", uid) else: obj.clients[uid].call(func, **kwargs)
def _delete_symbol_index(symbol): """ Removes a symbol from the index. """ if len(symbol) == 1: db.srem(GLOBAL_INDEX_LETTER_TAG, symbol.upper())
def _remove_post_tag_name(post_id, tag_name): """ Removes a post-id form the set of tag-name -- post-ids. """ db.srem(tag_name + APPEND_TAG_NAME_POSTS, str(post_id)) if db.scard(tag_name + APPEND_TAG_NAME_POSTS) == 0: db.delete(tag_name + APPEND_TAG_NAME_POSTS)