コード例 #1
0
ファイル: manager.py プロジェクト: 7flying/yil-pil
def _vote_post_categories(post_id, positive):
    """ Propagates the voting to every category in with the post is."""
    for tag in get_post_tags(str(post_id)):
        if positive:
            db.zincrby(tag.upper() + APPEND_POPULAR_POSTS_CATEGORY, post_id, 1)
        else:
            db.zincrby(tag.upper() + APPEND_POPULAR_POSTS_CATEGORY, post_id, -1)
コード例 #2
0
ファイル: manager.py プロジェクト: 7flying/yil-pil
def _inc_dec_tag(tag_name, add=True):
    """ Increments or decrements the counter of a tag. """
    if tag_name != None and len(tag_name) > 0:
        if add:
            debug("INC TAG USAGE: "+ tag_name)
            db.zincrby(POPULAR_TAGS, tag_name, 1)
        else:
            debug("DEC TAG USAGE: "+ tag_name)
            db.zincrby(POPULAR_TAGS, tag_name, -1)
            # Delete the tag from the list if it has a score of 0
            #if db.zrank(POPULAR_TAGS, tag_name) == 0:
            if _alternative_score(tag_name) == 0:
                # Delete from the specifig index of tag[0] -- tags
                _delete_tag_index_letter_tags(tag_name)
                # Delete from the index of tags if the tag is the last on index
                num = get_tags_by_index_letter(tag_name[0])
                if num != None and len(num) == 0:
                    _delete_symbol_index(tag_name[0])
                db.zrem(POPULAR_TAGS, tag_name)
コード例 #3
0
ファイル: manager.py プロジェクト: 7flying/yil-pil
def _vote_global(post_id, positive):
    """ Propagates the voting to the global ranking of posts. """
    if positive:
        db.zincrby(POPULAR_TOP_POSTS, post_id, 1)
    else:
        db.zincrby(POPULAR_TOP_POSTS, post_id, -1)